Parse a xml attribute depending on child content

Posted by eddiefernberg on Stack Overflow See other posts from Stack Overflow or by eddiefernberg
Published on 2010-12-31T01:30:47Z Indexed on 2010/12/31 1:54 UTC
Read the original article Hit count: 534

Filed under:
|
|
|

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!

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml