Jump to content

Parse the nested variables in XML using PHP


raaks

Recommended Posts

I have been playing with XML and PHP, I have googled to get the requirement which I am working on but still Im not getting the things the way I wanted.

 

I have got a XML file with nested variables, I need to parse the variables such as user_id, name and store it in an array, so that I need to use them to change the details in another config file.

 

For ex: if the user is logged in, using the user_id, i need to parse the all the data of the particular user from the XML file (where the details of the various users are stored).

 

Until now I could only parse the data and echo all of it but could not find a way to store this parsed information.

 

This is my "test.xml" file:

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
    <user>
        <user_id>0121</user_id>
        <name>Tim</name>
        <file>0121.file</file>
    </user>

    <user>
        <user_id>0178</user_id>
        <name>Henry</name>
        <file>0178.file</file>
    </user>

    <user>
        <user_id>0786</user_id>
        <name>Martin</name>
        <file>0786.file</file>
    </user>

    <user>
        <user_id>1239</user_id>
        <name>Jan</name>
        <file>1239.file</file>
    </user>
</document>

 

Any valuable information would be greatly helpful

 

Thanks Raaks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.