Jump to content

XML Parsing


pritis_dwibedi

Recommended Posts

Hello,

 

i am really in need of some help. i want to read the values from a xml based on some specific node value.

for example i want the resources present in second configuration file having id=1.

 

please do solve my problem, i have been trying this problem from last two days, its urgent.

 

thank you,

pritish

 

my xml is:

 

<configuration>

  <id>0</id>

  <systemId>1</systemId>

  <name>USER-1</name>

  <resource>

            <id>1</id>

            <systemId>1</systemId>

</resource>

<resource>

<id>2</id>

<systemId>1</systemId>

</resource>

</configuration>

<configuration>

  <id>1</id>

  <systemId>2</systemId>

  <name>USER-2</name>

  <resource>

            <id>1</id>

            <systemId>1</systemId>

</resource>

<resource>

<id>2</id>

<systemId>1</systemId>

</resource>

</configuration>

<configuration>

  <id>2</id>

  <systemId>3</systemId>

  <name>USER-3</name>

  <resource>

            <id>1</id>

            <systemId>1</systemId>

</resource>

<resource>

<id>2</id>

<systemId>1</systemId>

</resource>

</configuration>

 

 

Link to comment
https://forums.phpfreaks.com/topic/166930-xml-parsing/
Share on other sites

this is from php documentation:

 

$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
<movie>
  <title>PHP: Behind the Parser</title>
  <characters>
   <character>
    <name>Ms. Coder</name>
    <actor>Onlivia Actora</actor>
   </character>
   <character>
    <name>Mr. Coder</name>
    <actor>El Act&#211;r</actor>
   </character>
  </characters>
  <plot>
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  </plot>
  <great-lines>
   <line>PHP solves all my web problems</line>
  </great-lines>
  <rating type="thumbs">7</rating>
  <rating type="stars">5</rating>
</movie>
</movies>
XML;

$xml = new SimpleXMLElement($xmlstr);

echo $xml->movie[0]->plot; // "So this language. It's like..."

Link to comment
https://forums.phpfreaks.com/topic/166930-xml-parsing/#findComment-880156
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.