Jump to content

I'm doing something stupid... help.


defeated

Recommended Posts

Hi I have a problem.  I am transferring info from one site to another using xml.  I can get it to work if I have the xml in a file, but I don't want it in a file. I want it in a string.  I tried

 

$xml="<?xml version='1.0' encoding='UTF-8'?>
<transaction>
<name>Gordon Smyth</name>
<age>15</age>
<content><![CDATA[<p>Just some random text</p><ul><li>asfsaf</li><li>saasffdasf</li></ul>]]></content>
</transaction>" ;

but the "<?xml" bit causes a problem for some reason.  I'm sure I'm just doing something stupid with the syntax but I don't know what.  Please help.

Link to comment
https://forums.phpfreaks.com/topic/141925-im-doing-something-stupid-help/
Share on other sites

???  I don't follow.  I'm using simplexml to parse the data the other end.  Do you mean

$xml=simplexml("<?xml version='1.0' encoding='UTF-8'?>
<transaction>
   <name>Gordon Smyth</name>
   <age>15</age>
   <content><![CDATA[<p>Just some random text</p><ul><li>asfsaf</li><li>saasffdasf</li></ul>]]></content>
</transaction>") ;

That gives an undefined function error and without quotes gives an unexpected "<" error.  Also I could be in real trouble if any of the CDATA contents contained quotes which is quite possible.  Would I be better off writing a temp file and then deleting it?  I have avoided that because I don't know how yet.... but I'm sure it's not too hard.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.