0

I need to parse all data from below XML file. Please guide me how can I do it? How can I put data into a separate variables or array. Like, the value of <p:productid> tag into $pid and value of <p1:devices> into $pdevice?

Here is a sample file:

<?xml version="1.0" encoding="UTF-8"?>
  <p:application>


      <p1:devices>
         <p1:device>First device</p1:device>
         <p1:device>Second Device</p1:device>
     </p1:devices>    

 </p:versions> 
</p:application>
1

1 Answer 1

2

You can use the SimpleXML for that.

Here is a good tutorial to get you started:

Introduction To SimpleXML With PHP

Sign up to request clarification or add additional context in comments.

3 Comments

bro i see those examples..but cannot solved my issue.this xml are discontinious..can u pls write a sample code for me?? thanks for ur ans..
@riad: Well bro, we are supposed to answer questions, not do-this-for-me anyways. I would strongly recommend you to learn those as you might confront them in the future too :)
just tell me a single thing how can i parse data between < p3:appAccess > < /p3:appAccess > tag because xml perser can easily parse data from < appAccess > tag but here have an extra vale like p3: so its show ing error..pls help..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.