<?xml version="1.0" encoding="UTF-8"?> 
<form>
    <field name=”name”>VALUE</field> 
    <field name=”lastname”>VALUE</field> 
    <field name=”country”>VALUE</field> 
    <field name=”usstate”>VALUE</field> 
    <field name=”email”>VALUE</field> 
    <field name=”password”>VALUE</field> 
    <field name=”type”>VALUE</field> 
    <field name=”iscustomer”>1|0</field> 
    <field name=”newsletter”>1|0</field> 
    <field name=”privacy”>1|0</field> 
    <field name="udid">VALUE</field> 
    <field name="hash">VALUE</field>
</form>
            Asked
            
        
        
            Active
            
        
            Viewed 702 times
        
    -1
            
            
        
        flaviusilaghi
        
- 677
 - 3
 - 10
 - 27
 
- 
                    I don't know how since i am not a php programmer. – flaviusilaghi May 02 '11 at 11:27
 - 
                    [PHP manual: SimpleXML: Basic usage](http://php.net/manual/en/simplexml.examples-basic.php) – Pekka May 02 '11 at 11:29
 - 
                    possible duplicate of [A simple program to CRUD node and node values of xml file](http://stackoverflow.com/questions/4906073/a-simple-program-to-crud-node-and-node-values-of-xml-file) – Gordon May 02 '11 at 11:42
 
3 Answers
1
            Why negative votes? This is a legitimate question, isn't it!? I've seen stupider.
You want: simplexml_load_string
$xmlString = ' your xml ';
$xml = simplexml_load_string($xmlString);
// jimy's code here
        Rudie
        
- 52,220
 - 42
 - 131
 - 173
 
- 
                    I've seen stupider too, but is our mission really to save people from taking a 1-minute look into the manual? – Pekka May 02 '11 at 12:31
 - 
                    
 
0
            
            
        $xml = simplexml_load_file('path_to_file');
foreach($xml->children() as $child){ 
     print_r($child);
}
        jimy
        
- 4,848
 - 3
 - 35
 - 52
 
- 
                    Fatal error: Call to a member function children() on a non-object – flaviusilaghi May 02 '11 at 11:32
 - 
                    
 
0
            
            
        The XML you posted isn't actually readable - you're using a mix of double quote styles in the example you copied. If you fix that, this code will convert what you want into an associative array:
<?php
$xml = simplexml_load_file("test.xml");
$values = array();
foreach($xml->children() as $child)
{ 
    $values[(string)$child->attributes()] = (string) $child[0];
}
print_r ($values);
?>
        Oliver Emberton
        
- 951
 - 4
 - 14