Following are the Different examples to Parse the XML
Suppose you having following XML, to Parse
http://php-tutorial-php.blogspot.in/rss.xml?redirect=false&start-index=1&max-results=2
Example 1
$fileData = file_get_contents('http://php-tutorial-php.blogspot.in/rss.xml?redirect=false&start-index=1&max-results=2');
$output = simplexml_load_string($fileData);
echo "";";
print_r($output);
echo "
Example 2
$fileData = file_get_contents('http://php-tutorial-php.blogspot.in/rss.xml?redirect=false&start-index=1&max-results=2');
$domxml = DOMDocument::loadXML($fileData);
$output= simplexml_import_dom($domxml);
echo "";";
print_r($output);
echo "
Example 3
$xmlDoc = new DOMDocument();
$xmlDoc->load('http://php-tutorial-php.blogspot.in/rss.xml?redirect=false&start-index=1&max-results=2');
$x = $xmlDoc->documentElement;
foreach ($x->childNodes AS $item)
{
print $item->nodeName . " = " . $item->nodeValue . "\n";
}
}
Example 4
$fileData = file_get_contents('http://php-tutorial-php.blogspot.in/rss.xml?redirect=false&start-index=1&max-results=2');
$output = new SimpleXMLElement($fileData);
echo "";";
print_r($output);
echo "
0 Comment:
Post a Comment