Jump to content

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.

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.