-1

I need some php code to read this XML, and take the content of the <title> tags and declare as a $title variable. And the same for the <tags> and <content> as $tags and $content variables respectively.

The XML is listed below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<page>
    <title>Example title</title>
    <tags>example,title,page</tags>
    <content>This page has some lovely example content</content>
</page>
ir-g
  • 252
  • 1
  • 3
  • 18
  • 2
    One of many similar questions: [Simple XML reading question (PHP)](http://stackoverflow.com/questions/2074473/simple-xml-reading-question-php) –  Apr 20 '13 at 15:30

2 Answers2

1

this has been talked many times on stackoverflow, try to learn about simplexml. you need to load the file and then loop inside

$data = simplexml_load_string($xml);
foreach($data as $key => $val)
    echo "$key=>$val" . "<br>";

live working sample -> http://codepad.viper-7.com/6r1Tnd

Fabio
  • 23,183
  • 12
  • 55
  • 64
0

You need to read loadXML. The link describes this function and gives some example code on how to use it.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127