Jump to content

php XML DOM converts < and > to < and &qt; when assigning nodeValue


letoii

Recommended Posts

I am trying to assign a text value to an XML node.

 

$Data->nodeValue = '<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:'.$URN_UUID_ATTACHMENT.'" />'

 

The resulting xml is:

<Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:1294192877" /></Data>

 

is there a way to generate this instead:

<Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:1294192877" /></Data>

Link to comment
Share on other sites

i suggest that you modify the code that reads the xml <Data> element to un-format the html encoding as needed.

The code that reads the XML is this:

 

$doc = new DOMDocument();
$doc->load('../../_xml/callxml/uploadFile.xml');

$DataNodes = $doc->getElementsByTagName('Data');
$Data = $DataNodes->item(0);

 

Where should the formatting be altered?

Link to comment
Share on other sites

OK, I see my mistake. xop:include is actually a node. I can't write it in like regular text.

 

Correct way to do this is:

 

$xop = new DOMElement("xop:Include","","http://www.w3.org/2004/08/xop/include");
$xopNode = $Data->appendChild($xop);
$xopNode->setAttribute("href","cid:".$URN_UUID_ATTACHMENT);

 

Link to comment
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.