Jump to content

Recommended Posts

I am reading in a file. Here is one of the tags from the XML.

<PropertyURL>http://developer.newcondosonline.com/direct1.php?property=1568&amp;pname=The Potrero&amp;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

Hi

 

This worked for me using PHP5:

 

<?php
$file = "<PropertyURL>http://developer.newcondosonline.com/direct1.php?property=1568&amp;pname=The Potrero&amp;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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.