Jump to content

Xml Creation Through Php


Guest anuj kumar
 Share

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.

Edited by Ingolme
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...