tillurdizzy / x2js

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

CDATA not handled properly #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Parsing an XMLDoc
2.
3.

What is the expected output? What do you see instead?
CDATA content should be handled as text. Instead, CDATA blocks come undefined.  

My quick fix for this:

if (childName == '#cdata-section') {
  result['#text'] = child.textContent || child.innerText;
} else {
  if(result[childName] == null) {
    result[childName] = parseDOMChildren(child);
    result[childName+"_asArray"] = new Array(1);
    result[childName+"_asArray"][0] = result[childName];
  } else {
    if(result[childName] != null) {
      if( !(result[childName] instanceof Array)) {
        var tmpObj = result[childName];
        result[childName] = new Array();
        result[childName][0] = tmpObj;
        result[childName+"_asArray"] = result[childName];
      }
    }
    var aridx = 0;
    while(result[childName][aridx]!=null) aridx++;
    (result[childName])[aridx] = parseDOMChildren(child);
  }
}

Original issue reported on code.google.com by gvg.f...@gmail.com on 22 Jun 2012 at 9:09

GoogleCodeExporter commented 9 years ago
CDATA now is available in v1.0.6.
Now you can use additional system property __cdata - look at last samples.
Thanks for submit issue. 

Original comment by abdulla....@gmail.com on 22 Jun 2012 at 9:34

GoogleCodeExporter commented 9 years ago

Original comment by abdulla....@gmail.com on 18 Oct 2012 at 9:06