Jump to content

Xml Creation Through Php


Guest anuj kumar

Recommended Posts

Guest anuj kumar

Hi , I am creating XML through php DOMdocument. i am creating an element in xml and assigning it a value which is coming from a varible in my php script. after that i am accessing that xml element in my java script by getElementsByTagName()[0].firstChild.nodeValue, this is working fine in firefox and chrome but ie is throwing and error 'object required' at this line. the strange part of this is at the time of assigning a value to that element in php if i hardcode the same value of that variable than it works fine. means suppose $cat_id is having value 1; $dom->createElement('CATID',$cat_id); doesn't work in ie but works in other browsers. $dom->createElement('CATID',1); works fine in ie too. but in both cases xml is same ,if you will see the xml in browser. I am totally clueless what's going wrong if i assign that variable to that element in XML. i even checked the bytes through wireshark but it is same in both the cases.please help me out.

Link to comment
Share on other sites

I wasn't aware of a second parameter in the createElement function.You should do this instead:

$x = $dom->createElement('CATID');$y = $dom->createTextNode($cat_id);$x->appendChild($y);

Check in Internet Explorer to see if getElementsByTagName("CATID")[0].childNodes.length is greater than 0.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...