Genadinik
Genadinik

Reputation: 18649

Parsing XML with PHP

I have a simple xml file. I know which fields it will have ahead of time. What can you guys recommend is the best way for me to get the value of those fields using php?

Thank you :)

Upvotes: 1

Views: 141

Answers (3)

bensiu
bensiu

Reputation: 25604

You can go with XML Parser, however the nice and simply way is to use SimpleXML

Upvotes: 0

Jesse Cohen
Jesse Cohen

Reputation: 4040

Simplexml works great.

Upvotes: 5

user142162
user142162

Reputation:

SimpleXML is great for quick reading/writing of XML files. Here's an example:

<root>
   <node>
      <sub>Text</sub>
   </node>
</root>

 

$xml = new SimpleXMLElement('xml_file.xml', 0, true);
echo $xml->node->sub; // Displays "Text"

Upvotes: 7

Related Questions