Tag Archives: xml

PHP – very basic XMLReader

Questions: Because I will be parsing a very large XML file, I am trying to use XMLReader to retrieve the XML data, and use simpleXML to display. I have never used XMLreader, so I am simply trying to get a basic feel for using XMLReader. I want to display all the name and price values… Read More »

PHP: Accessing namespaced XML with SimpleXML

Questions: I’m using simplexml() function to parse through RSS feed, while i can access $var->title to <title> how do I access <dcterms:issued>? Feed excerpt (http://pastebin.com/nN8G78AH): <item rdf:about=”http://newyork.craigslist.org/brk/mcy/1779690213.html”> <title><![CDATA[Kawasaki ZX-10R Rims For Sale (Nassau Motorsports)]]></title> <link>http://newyork.craigslist.org/brk/mcy/1779690213.html</link> <description><![CDATA[ <br> <br> 2000 KAWASAKI ZX-12R <br> <br> FRONT & REAR RIMS W/FRONT & REAR ROTORS <br> <br> RIMS ARE… Read More »

PHP sorting issue with simpleXML

Questions: test.xml: <?xml version=”1.0″?> <props> <prop> <state statename=”Mississippi”> <info> <code>a1</code> <location>Jackson</location> </info> <info> <code>d2</code> <location>Gulfport</location> </info> <info> <code>g6</code> <location>Hattiesburg</location> </info> </state> <state statename=”Texas”> <info> <code>i9</code> <location>Dallas</location> </info> <info> <code>a7</code> <location>Austin</location> </info> </state> <state statename=”Maryland”> <info> <code>s5</code> <location>Mount Laurel</location> </info> <info> <code>f0</code> <location>Baltimore</location> </info> <info> <code>h4</code> <location>Annapolis</location> </info> </state> </prop> </props> test.php // start the sortCities… Read More »

XML Extra content at the end of the document

Questions: I’m getting this error: error on line 4 at column 1: Extra content at the end of the document with this code: $this->load->database(); function parseToXML($htmlStr) { $xmlStr=str_replace(‘<‘,’&lt;’,$htmlStr); $xmlStr=str_replace(‘>’,’&gt;’,$xmlStr); $xmlStr=str_replace(‘”‘,’&quot;’,$xmlStr); $xmlStr=str_replace(“‘”,’'’,$xmlStr); $xmlStr=str_replace(“&”,’&amp;’,$xmlStr); return $xmlStr; } $query = $this->db->get(‘comboTable’); $query = $query->result_array(); header(“Content-type: text/xml”); // Start XML file, echo parent node echo ‘<markers>’; // Iterate through… Read More »

How to fix 411 Length Required error with file_get_contents and the expedia XML API? [closed]

Questions: I am doing the online hotel booking using xml api(php) project.When i am working in the reservation code it shows error of the following “Warning: file_get_contents(https://…@gmail.com</email><firstName>test</firstName><lastName>smith</lastName><homePhone>8870606867</homePhone><creditCardType>CA</creditCardType><creditCardNumber>5401999999999999</creditCardNumber>….</HotelRoomReservationRequest>) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 411 Length Required” its my code $context = stream_context_create( array( ‘http’ => array( ‘method’ => ‘POST’, ‘header’ => “Content-type:… Read More »

Why when add <?xml version=“1.0” encoding=“utf-8”?> to web page don´t work on hosting?

Questions: I am developing a simple webpage at hostgator.com. I have the standard headers, but when I add the following line: <?xml version=”1.0″ encoding=”utf-8″?> the page does not work. I would like why. This is the full header: <?xml version=”1.0″ encoding=”utf-8″?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” lang=”es” xml:lang=”es”> …… Read More »

Parsing XML using PHP

Questions: I’ve consistently had an issue with parsing XML with PHP and not really found “the right way” or at least a standardised way of parsing XML files. Firstly i’m trying to parse this: <item> <title>2884400</title> <description><![CDATA[ ><img width=”126″ alt=”” src=”http://userserve-ak.last.fm/serve/126/27319921.jpg” /> ]]></description> <link>http://www.last.fm/music/+noredirect/Beatles/+images/27319921</link> <author>anne710</author> <pubDate>Tue, 21 Apr 2009 16:12:31 +0000</pubDate> <guid>http://www.last.fm/music/+noredirect/Beatles/+images/27319921</guid> <media:content url=”http://userserve-ak.last.fm/serve/_/27319921/Beatles+2884400.jpg” fileSize=”13065″… Read More »

XMLHttpRequest to open PDF in browser

Questions: I want to do XMLHttpRequest and then open a PDF in the Browser by sending the filename by POST method. xmlhttp.open(“POST”,”pdf.php”,true); //CHANGE xmlhttp.setRequestHeader(“Content-type”,”application/x-www-form-urlencoded”); xmlhttp.send(“file=”+input); Is that possible or XMLHttpRequest is just for HTML? Answers: