Skip to main content
simplexml has no underscore
Link
IMSoP
  • 99.7k
  • 18
  • 135
  • 183

SIMPLE_XML SimpleXML Lower level variable

Source Link

SIMPLE_XML Lower level variable

I'm parsing a file with simple_xml_load_file(), level by level. Here's the sample structure:

<person name="Joe Smith" ...> <info age="19"> <height val="1.85" /> </info> <info age="19"> <weight val="82" /> </info> <info age="19"> <build val="14" /> </info> </person> ... 

As I am parsing I am not going deep, as I don't need to. I do need the age however, without going through each info tag. I need the variables contained in <person> and only the age. How would I go about getting age without another loop?

$persons=$dom->person; foreach($persons as $person){ $name=$person['name']; $age=???? }