Parse a xml attribute depending on child content
- by eddiefernberg
Hello!
I load an external xml file containing user metas looking like this:
<?xml version="1.0" encoding="utf-8"?>
<user_information>
<user url="http://usersweb.com">
<name>Arnold</name>
<lastname>
<name>Arnoldson</name>
</lastname>
<age>42</age>
</user>
<user url="http://anotheruserweb.com">
<name>Arnold</name>
<lastname>
<name>Arichson</name>
</lastname>
<age>42</age>
</user>
And so on....
</user_information>
I know the formatting with
<lastname>
is really stupid, but i can't modify the source.
I want to load in the "url"-attribute from
<user>
, but only if
<name>
and
<lastname>
matches the name values i have stored in my own user database.
I know how to parse the rest of it with PHP, but just the matching sequence seems difficult to me. Any help appreciated!