CoreyR Posted June 5, 2007 Share Posted June 5, 2007 I am reading in a file. Here is one of the tags from the XML. <PropertyURL>http://developer.newcondosonline.com/direct1.php?property=1568&pname=The Potrero&compid=626</PropertyURL> When I grab the URL all I get is "compid=626" because the & breaks the data. Anyone know how to bring this in without breaking this? Or, possibly replace the characters when I down load the file? $sf = "http://developer.newcondosonline.com/rss-properties-san-francisco.xml"; $sfxml = "sf.xml"; $source = $sf; $dest = $sfxml; if (!copy($source, $dest)) {print ("failed to copy $dest. It is possible the XML feed has been changed, please check with provider.<br>\n");} Link to comment https://forums.phpfreaks.com/topic/54219-reading-xml-with-php/ Share on other sites More sharing options...
leap500 Posted June 5, 2007 Share Posted June 5, 2007 Hi This worked for me using PHP5: <?php $file = "<PropertyURL>http://developer.newcondosonline.com/direct1.php?property=1568&pname=The Potrero&compid=626</PropertyURL>"; $xml = simplexml_load_string($file); print_r($xml); ?> The output is: SimpleXMLElement Object ( [0] => http://developer.newcondosonline.com/direct1.php?property=1568&pname=The Potrero&compid=626 ) You would need to use simplexml_load_file as it is an external file. See http://www.php.net/manual/en/ref.simplexml.php for more info. Link to comment https://forums.phpfreaks.com/topic/54219-reading-xml-with-php/#findComment-268807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.