Member Avatar

The following code produces the XML file that I am after. $dom = new DOMDocument('1.0', 'UTF-8'); // pretty formatting $dom->formatOutput = true; // create root element $root = $dom->createElement('Poem'); $root->setAttribute('object_id', '542'); $dom->appendChild($root); // create title element $title = $dom->createElement('title'); $root->appendChild($title); // create a node for the title element $text = $dom->createTextNode('The Unknown Poem'); $title->appendChild($text); // save xml as string $test = $dom->saveXML(); echo($test); $dom->save('testDOM.xml'); I get `testDom.xml` contaning the details that I need. However, the `echo($test);` prints nothing. What might be the cause I wonder? I tried `print_r()` too. Any suggestions? ## Additional Information ## XAMPP (on Win 8) is …

Member Avatar
0
31
Member Avatar

I'm trying to create an xml document without converting html entities but when I create and save the file with DOMDocument the < and > characters are converted to &lt; and &gt; so trying to wrap copy within <![CDATA[]]> is proving problematic. Example of my code below: // Initiate the XML $doc = new DOMDocument('1.0', 'UTF-8'); $doc->formatOutput = true; $r = $doc->createElement("advertising"); $doc->appendChild($r); // <ad> $ad = $doc->createElement('ad'); // <TITLE> $title = $doc->createElement('TITLE'); $title->appendChild($doc->createTextNode('<![CDATA['.$v_title.']]>')); $ad->appendChild($title); // </ad> $r->appendChild($ad); // Save xml $doc->saveXML(); $doc->save('ads.xml'); Could anyone tell me how I prevent this?

Member Avatar
0
3
Member Avatar

I am starting out with PHP and in my project I'm trying to fetch XML data from a url and parsing it for data. Now the url that I use is being fetched from a webpage and hence I know that it is correct and it exists. Still, when I try to execute the page I get the following errors: [ICODE] Warning: DOMDocument::load() [domdocument.load]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\Users\Siddharth Dahiya\Dropbox\www\Site\includes\tw_worlds.php on line 138 [/ICODE] The code in question is: [CODE=PHP] //Problem function function PopulateSettings() { set_time_limit(60000); //Lots of data hence large load time... $rtnVal = …

Member Avatar
0
2
Member Avatar

hey people, i have the following problem, i'm setting up a webshop with over 2k items and every 6months the prices are changing(wines) so i was wondering how to import an xml file into a mysql database without having to go in phpmyadmin. this because i don't want the people for who i'm making the website have access there to destroy the whole database. this is what i got so far: [CODE]<?php include "header.php"; ?> <br><br><br> <h1>Database updaten</h1> <form enctype="multipart/form-data" action="import.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="20000000" /> <table width="600"> <tr> <td>Names file:</td> <td><input type="file" name="file" /></td> <td><input type="submit" value="Upload" /></td> …

Member Avatar
0
37

The End.