I have a xml file created by using php domdocument. I want to display the xml file in webpage. I google it, and find the following help:
http://www.phpbuilder.com/manual/en/fun ... avexml.php
In this web page the following code
Code: Select all
<?php
$doc = new DOMDocument('1.0');
// we want a nice output
$doc->formatOutput = true;
$root = $doc->createElement('book');
$root = $doc->appendChild($root);
$title = $doc->createElement('title');
$title = $root->appendChild($title);
$text = $doc->createTextNode('This is the title');
$text = $title->appendChild($text);
echo "Retrieving all the document:\n";
echo $doc->saveXML() . "\n";
echo "Retrieving only the title part:\n";
echo $doc->saveXML($title);
?>
<?xml version="1.0"?>
<book>
<title>This is the title</title>
</book>
I tested, it will only print the value of the element, not the xml file. It will print only:
this is the title.
How can I display the entire xml file. I want the the output as:
<?xml version="1.0"?>
<book>
<title>This is the title</title>
</book>
Thanks