patelneel1994 / x2js

Automatically exported from code.google.com/p/x2js
0 stars 0 forks source link

Comments before root fix #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Comments before the root-element = error

Possible solution:

function parseDOMChildren( node ) {
  if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) {
    var result = new Object;
    //var child = node.firstChild; //No good 
    var child = node.firstElementChild; //Better. Skips comments <!-- -->
    var childName = getNodeLocalName(child);
    result[childName] = parseDOMChildren(child);
    return result;
 }
 ...
 .

Original issue reported on code.google.com by jmj.bak...@gmail.com on 11 Oct 2013 at 11:02

GoogleCodeExporter commented 9 years ago

Original comment by abdulla....@gmail.com on 12 Oct 2013 at 10:53

GoogleCodeExporter commented 9 years ago
It looks like there are some compatibility issues with some actual IE browsers 
for firstElementChild (hate it)
https://developer.mozilla.org/en-US/docs/Web/API/ParentNode.firstElementChild. 

I've just fixed it in v1.1.3 with some additional code :(

Original comment by abdulla....@gmail.com on 12 Oct 2013 at 11:25

GoogleCodeExporter commented 9 years ago

Original comment by abdulla....@gmail.com on 12 Oct 2013 at 11:25

GoogleCodeExporter commented 9 years ago
Ohhh... You are right. IE throws an error. Safari too. (hate them both)
Thank you again :)

Original comment by jmj.bak...@gmail.com on 12 Oct 2013 at 3:32

GoogleCodeExporter commented 9 years ago
No problem, v1.1.3 is released

Original comment by abdulla....@gmail.com on 16 Oct 2013 at 7:25