afraxas / x2js Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/x2js
Automatically exported from code.google.com/p/x2js
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system and
browser version?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 13 Jan 2015 at 11:37
What steps will reproduce the problem?
1. xml = "<out><test>foo & bar</test></out>";
2. json = x2js.xml_str2json(xml);
What is the expected output?
json = {"out":{"test":"foo & bar"}}
What do you see instead?
json = null
What version of the product are you using? On what operating system and
browser version?
I'm on Firefox and It doesn't work on https://x2js.googlecode.com/hg/demo.html
I think this is the lastest version ...
Is there a fix or something to do ?
I can't modify xml that comes from the server.
Modifications have to be done on the xml or the plugin ?
Thanks in advance!
Original issue reported on code.google.com by [email protected]
on 2 Mar 2015 at 12:37
Imagine you have an xml file in which an element is repeated zero or more
times. You could have these three files following that scheme:
File 1:
<a></a>
File 2:
<a><b>1</b></a>
File 3:
<a><b>1</b><b>2</b></a>
Now, if I convert this xml to the object "obj", obj.a.b can either be
undefined, a string or an array of strings. x2js.asArray(obj.a.b) will always
be an array. However, for files 2 and 3 it will be an array of strings, while
for file 1 it will be [undefined], while what I (clearly) wanted was an empty
array (of strings).
Returning an empty array should be simple in this case and will help prevent
errors when it turns out the element you are looking for is repeated zero times.
Original issue reported on code.google.com by [email protected]
on 27 Jun 2014 at 11:26
Problem:
Namespace url http://www.example.org turns to http:://www.example.org
when converting from JSON to XML.
What steps will reproduce the problem?
1. Run the the x2js html sample using the sample json:
{"MyOperation":{"test":"Success","test2":{"item":["ddsfg","dsdgfdgfd"],"item2":"
testArrSize","_myAttr":"SuccessAttrValueTest2"},"_xmlns:testns":"http:://www.exa
mple.org","__prefix":"testns"}}
What is the expected output?
<testns:MyOperation
xmlns:testns='http://www.example.org'><test>Success</test><test2
myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item><item2>te
stArrSize</item2></test2></testns:MyOperation>
What do you see instead?
<testns:MyOperation
xmlns:testns='http:://www.example.org'><test>Success</test><test2
myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item><item2>te
stArrSize</item2></test2></testns:MyOperation>
What version of the product are you using? On what operating system and
browser version?
x2js v 1.1.5
Chrome v 33.0.1750.117
OS X 10.9.1
Original issue reported on code.google.com by [email protected]
on 2 Mar 2014 at 12:51
Hi,
little bug I found:
trim() function is not supported in IE8, which you use in the library.
IE8 would fail with message: Object doesn't support this property or method
Solution:
http://stackoverflow.com/questions/11219731/trim-function-doesnt-work-in-ie8
Original issue reported on code.google.com by [email protected]
on 9 Jan 2014 at 11:38
What steps will reproduce the problem?
1. Call 'new X2JS().xml_str2json(longXmlString)', in my case
longXmlSting.length = 61426685
What is the expected output? What do you see instead?
I am expect json object but null is returned.
What version of the product are you using? On what operating system and
browser version?
Version: v1.1.4
OS: Windows 7 64x
Browser: IE10/11
Please provide any additional information below.
When debug I have found that error 'Not enough storage is available to complete
this operation' caught in xml2json.js file line 501.
Original issue reported on code.google.com by [email protected]
on 1 Oct 2014 at 1:35
What steps will reproduce the problem?
Convert following xml to json
<element
href="https://host/api/query?type=field1&page=1&pageSize=25&format=r
eferences" />
And then convert it back to xml. In the resulting xml, ampersand is incorrectly
encoded:
<element
href='https://host/api/query?type=field1&page=1&pageSize=25&format=references'/>
Xml Parser reports error:
Unable to parse any XML input. org.jdom2.input.JDOMParseException: Error on
line 1: The reference to entity "page" must end with the ';' delimiter.
Please check if ampersand and other special characters are xml encoded
correctly.
What version of the product are you using? On what operating system and
browser version?
I am using the online demo as of now.
Original issue reported on code.google.com by [email protected]
on 26 Dec 2013 at 4:42
What steps will reproduce the problem?
1. Have embedded comments inside the XML, eg :
<stuff>
<things>
Value
<!-- a comment from somewhere -->
</things>
</stuff>
- unfortunately these are coming from a production system I have no control
over.
What is the expected output? What do you see instead?
I would expect to see :
{
"stuff": {
"things": "Value"
}
}
- instead I get :
{
"stuff": {
"things": {
"__text": "Value"
}
}
}
What version of the product are you using? On what operating system and
browser version?
latest xml2js code, and every browser - Chrome / IE / FF / etc
Please provide any additional information below.
Traced the issue to the source where you are checking the 'type' of XML node -
you need a check on line 73(ish) :
eg.... my fix commented with '//cje'
for(var cidx=0; cidx <nodeChildren.length; cidx++) {
var child = nodeChildren.item(cidx); // nodeChildren[cidx];
var childName = getNodeLocalName(child);
if(child.nodeType!=8) { //cje - not a COMMENT NODE
result.__cnt++;
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);
}
} //cje - end
}
Hope that helps !
Thanks
Chris
Original issue reported on code.google.com by [email protected]
on 15 Oct 2013 at 1:12
What steps will reproduce the problem?
1. Use an XML document containing an attribute with ':' in the attribute name,
like:
<container>
<test my:attrib="abc">
<d>hello world!</d>
</test>
</container>
2. Create an X2JS object and pass the test document:
var x = new X2JS();
x.xml_str2json('<container><test my:attrib="abc"><d>hello
world!</d></test></container>');
What is the expected output? What do you see instead?
Expected:
{
container: {
test: {
'_my:attrib': 'abc',
d: 'hello world!'
}
}
}
Got instead:
{
container: {}
}
What version of the product are you using? On what operating system and
browser version?
X2JS Version 1.1.7,
Windows 7, Chrome 39.0.2171.65
Please provide any additional information below.
It seems the DOMParser has the problem. However, it does not happen when the
mime type 'text/html' is used, with all others, the error happens. However,
X2JS does not parse correctly if this mime type is used.
Original issue reported on code.google.com by [email protected]
on 24 Nov 2014 at 5:37
What steps will reproduce the problem?
1. Pass a XML string to x2js.xml_str2json()
2.
3.
What is the expected output?
I expect a JSON object representation of the XML
What do you see instead? ReferenceError: "ActiveXObject" is not defined
What version of the product are you using? 1.1.5
On what operating system and browser version? using it in a server-side
scripting.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 30 Jul 2014 at 10:42
What steps will reproduce the problem?
1. Parse an XML string containing namespaced elements *and attributes* into
JSON.
2. Note that while namespaces are stripped from the element names (which become
keys in the JSON), the namespaces are still present in the attribute key names.
I'm not sure if this is deliberate or not, but it seems like it should be
consistent. Since namespaces are removed from the element names in the JSON
output, it seems like they should be removed from the attribute names as well.
The namespace IS properly populated in the "__prefix" key for attributes, so
it's there is someone needs it (just as it is for elements).
Also, not sure if this would affect the translation from JSON back to XML. If
it doesn't already, I'd say it should take the __prefix and prepend it to the
attribute name, which is how I assume it already works for elements?
Original issue reported on code.google.com by [email protected]
on 23 Jan 2015 at 3:40
Looking for a way to avoid the "old" <element>_asArray and still have the
opportunity to have nested multiple elements (arrays in arrays)
Example:
-------------
var x2js = new X2JS();
var json = x2js.xml2json(xmldoc);
x2js.asArray(json.setup.icons.icon);
x2js.asArray(json.setup.templates.template); //asArray OK
x2js.asArray(json.setup.templates.template.states.state); //DOOOOhhh!!
-------------
Uncaught TypeError: Cannot read property 'state' of undefined
-------------
It makes sense. Fundamental stufff :) I need to loop all states and call
asArray on each template.
But it would be real nice if there was a way anyway.. Maybe a naming
convention... something like:
var x2js = new X2JS();
x2js.becomesArray("json.setup.icons.icon");
x2js.becomesArray("json.setup.templates.template");
x2js.becomesArray("json.setup.templates.template.states.state");
var json = x2js.xml2json(xmldoc);
Original issue reported on code.google.com by [email protected]
on 11 Oct 2013 at 9:11
Added some 'missing' semicolons.
Thank you for sharing this code!
Original issue reported on code.google.com by [email protected]
on 14 Jun 2013 at 5:38
Attachments:
What steps will reproduce the problem?
1. processing xml with 'mixed' nodes (text nodes), eg :
<stuff>
<things>some value</things>
some text here
</stuff>
What is the expected output? What do you see instead?
- works fine in a 'proper browser' ;-)
in IE8 : causes "Object doesn't support this property or method"
What version of the product are you using? On what operating system and
browser version?
Latest, and IE8
Please provide any additional information below.
- tracked the issue to line 199 :
>>>
if ( result.__cnt > 1 && result.__text!=null &&
config.skipEmptyTextNodesForObj) {
if(result.__text.trim()=="") { // HERE IS THE PROBLEM
<<<
- ".trim()" doesn't exist on String.prototype in IE8 - suggest a new method, or
a polyfill for IE8
Cheers
Chris
Original issue reported on code.google.com by [email protected]
on 23 Oct 2013 at 12:24
When i use xml_str2json to get json object. It's work but that json had
[_asArray] attribute. The [_asArray] attribute was not work in my project.
So if you can let that attribute to option mode that be great.
Original issue reported on code.google.com by [email protected]
on 9 Aug 2013 at 7:28
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 [email protected]
on 11 Oct 2013 at 11:02
What steps will reproduce the problem?
1. Is there an official github repo for this project?
2. I made my own fork at https://github.com/cyrfer/x2js
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system and
browser version?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 18 May 2015 at 7:31
When calling json2xml_str()
When you have something like:
{ name: [ { first: 'Dean' } , { first: 'Dan' } ] }
The 'name' is dropped and only 2 <first> nodes are created
Alternatively, I noticed that children arrays were not being parsed in other
situations, and realzied it was due to line #198
The returned object was coming up blank because the node was 1 level deep. The
object contained attributes, but it did not know what the node name should be,
and as such returned an empty string.
So instead I changed the code to:
var item = {};
item[it] = subObj[arIdx];
result+=parseJSONObject(item);
Original issue reported on code.google.com by deansofer
on 16 Sep 2012 at 11:41
What steps will reproduce the problem?
Run these two lines in your JavaScript console:
1. var xmlStr = "<xml><title name='MODE'>show</title><title
name='VAR'>me</title></xml>"
2. X2JS.json2xml_str(X2JS.xml_str2json(xmlStr))
What is the expected output? What do you see instead?
Expected output: "<xml><title name='MODE'>show</title><title
name='VAR'>me</title></xml>"
Actual output: "<xml><title></title><title></title></xml>"
What version of the product are you using? On what operating system?
Using version 1.0.7 in Chrome
Please provide any additional information below.
I fixed this by making a 5 line change to version 1.0.6**. My file is attached.
The for loop at line 196 now is:
for(var arIdx = 0; arIdx < subObj.length; arIdx++) {
if(arrayOfObjects){
var arrObj = {};
arrObj[it] = subObj[arIdx];
result+=parseJSONObject(arrObj);
} else {
...
}}
** Link to version 1.0.6:
http://code.google.com/p/x2js/source/browse/xml2json.js?spec=svn8326889cdfbe9512
26417adbed94952ef9d7a06f&r=ee0824ba76a41fe7be65546e145ccd591f9dc662
Original issue reported on code.google.com by [email protected]
on 15 Oct 2012 at 2:55
Attachments:
1. Convert attached xml file to json format
Extpected output is
{
description: "< --> <"
}
Instead I see the following
{
description: "< --> <"
}
Version of the product is 1.1.5
Solution is change the order of replacing special characters in
unescapeXmlChars function.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 29 Aug 2014 at 1:55
Attachments:
What steps will reproduce the problem?
I use x2js.xml2json( javascript text string of attached file )
What is the expected output? What do you see instead?
Works as expected in Chrome, fails in Firefox v30 and IE10
I get object.observations.links (in Chrome)
I get object with no attributes (in IE and Firefox)
What version of the product are you using? On what operating system and
browser version?
v1.1.5
This is the only thing I've found this piece of software not able to decode
which says a lot! Great work!
Original issue reported on code.google.com by [email protected]
on 19 Jun 2014 at 2:25
Attachments:
When converting JSON to an XML string, I found that reserved XML characters
within the JSON tokens are not getting escaped. Can cause bad things to happen.
Haven't looked into it so I don't know if it's and issue, but you might want to
check that you are escaping reserved JSON characters when converting from XML
as well.
I can understand this might cause problems though if the tokens are already
escaped, so you might want to make it an optional feature.
underscore.js has an escaping function for reference.
Original issue reported on code.google.com by [email protected]
on 6 Jan 2013 at 4:29
Missing semicolon!
When this problem will be fixed? :D
Original issue reported on code.google.com by [email protected]
on 9 Dec 2011 at 2:36
Hi,
didn't find other way to contact you, so I'm posting my request here.
Let assume an XML:
<root>
<elementA>first</elementA>
<elementB>second</elementB>
<elementA>third</elementA>
<elementC>fourth</elementC>
<elementA>fifth</elementA>
<elementB>sixth</elementB>
</root>
Converting to json we get
- root
- elementA [array] - first, third, fifth
- elementB [array] - second, sixth
- elementC - fourth
Now is there a way to get the original order of elements?
Something like property originalIndex attached to each element?
elementA[0].originalIndex == 0 // first
elementA[1].originalIndex == 2 // third
elementA[2].originalIndex == 4 // fifth
elementB[0].originalIndex == 1 // second
elementB[1].originalIndex == 5 // sixth
elementC.originalIndex == 3 // fourth
Thanks for help.
Original issue reported on code.google.com by [email protected]
on 11 Dec 2013 at 1:51
What steps will reproduce the problem?
1. addind a xml file with namespaces in chrome
2. in firefox it works.
3.
What is the expected output? What do you see instead?
json
What version of the product are you using? On what operating system and
browser version?
ubuntu , chrome
Please provide any additional information below.
<?xml version="1.0" encoding="UTF-8"?><sv:node
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
xmlns:ns001="http://purl.org/dc/elements/1.1/dc:"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:cnt="http://www.w3.org/2011/content#"
xmlns:ns002="http://www.w3.org/1999/02/22-rdf-syntax-ns##"
xmlns:test="info:fedora/test/"
xmlns:fedoraconfig="http://fedora.info/definitions/v4/config#"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:image="http://www.modeshape.org/images/1.0"
xmlns:oax="http://www.w3.org/ns/openannotation/extensions/"
xmlns:fedorarelsext="http://fedora.info/definitions/v4/rels-ext#"
xmlns:premis="http://www.loc.gov/premis/rdf/v1#"
xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
xmlns:mode="http://www.modeshape.org/1.0"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:oa="http://www.w3.org/ns/oa#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
xmlns:authz="http://fedora.info/definitions/v4/authorization#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fedora="http://fedora.info/definitions/v4/rest-api#"
sv:name="0390"><sv:property sv:name="jcr:primaryType"
sv:type="Name"><sv:value>nt:folder</sv:value></sv:property><sv:property
sv:name="jcr:created"
sv:type="Date"><sv:value>2014-09-29T13:07:58.306+02:00</sv:value></sv:property><
sv:property sv:name="jcr:createdBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property><sv:node
sv:name="9ae8bb354ee659ad949829080c2a2df8"><sv:property
sv:name="jcr:primaryType"
sv:type="Name"><sv:value>nt:folder</sv:value></sv:property><sv:property
sv:name="jcr:mixinTypes" sv:type="Name"
sv:multiple="true"><sv:value>fedora:resource</sv:value><sv:value>fedora:object</
sv:value></sv:property><sv:property sv:name="jcr:uuid"
sv:type="String"><sv:value>a844128d-6614-4418-a6c1-7f9278ff6aba</sv:value></sv:p
roperty><sv:property sv:name="jcr:created"
sv:type="Date"><sv:value>2014-09-29T13:07:58.306+02:00</sv:value></sv:property><
sv:property sv:name="dc:description-de" sv:type="String"
sv:multiple="true"><sv:value>Die Familie des hier abgebildeten Goeslis von
Ehenheim lebte südlich von Straßburg und bekleidetet das Burgmannenamt in
Oberehenheim und Werd. Als Ritter ist er unter dem Namen Gozmar von Ehrenheim
1242 und 1276 urkundlich erwähnt, er ist jedoch wahrscheinlich nicht identisch
mit dem Minnesänger gleichen Namens.</sv:value></sv:property><sv:property
sv:name="jcr:lastModified"
sv:type="Date"><sv:value>2014-09-29T13:07:58.306+02:00</sv:value></sv:property><
sv:property sv:name="dc:language" sv:type="String"
sv:multiple="true"><sv:value>de</sv:value></sv:property><sv:property
sv:name="jcr:lastModifiedBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property><sv:property
sv:name="jcr:createdBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property></sv:node><sv:nod
e sv:name="903b6fc1-5415-34aa-8629-22a6a8c640c1"><sv:property
sv:name="jcr:primaryType"
sv:type="Name"><sv:value>nt:folder</sv:value></sv:property><sv:property
sv:name="jcr:mixinTypes" sv:type="Name"
sv:multiple="true"><sv:value>fedora:resource</sv:value><sv:value>fedora:object</
sv:value></sv:property><sv:property sv:name="jcr:uuid"
sv:type="String"><sv:value>4ec278de-ebf6-4c7a-81a3-90fc87b0a8f3</sv:value></sv:p
roperty><sv:property sv:name="dc:title" sv:type="String"
sv:multiple="true"><sv:value>Herr Goesli von
Ehenhein</sv:value></sv:property><sv:property sv:name="jcr:created"
sv:type="Date"><sv:value>2014-09-29T14:24:02.617+02:00</sv:value></sv:property><
sv:property sv:name="jcr:lastModified"
sv:type="Date"><sv:value>2014-09-29T14:24:02.617+02:00</sv:value></sv:property><
sv:property sv:name="jcr:lastModifiedBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property><sv:property
sv:name="jcr:createdBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property></sv:node><sv:nod
e sv:name="17117ca7"><sv:property sv:name="jcr:primaryType"
sv:type="Name"><sv:value>nt:folder</sv:value></sv:property><sv:property
sv:name="jcr:mixinTypes" sv:type="Name"
sv:multiple="true"><sv:value>fedora:resource</sv:value><sv:value>fedora:object</
sv:value></sv:property><sv:property sv:name="jcr:uuid"
sv:type="String"><sv:value>de92fcc5-b6ee-4dd5-b40d-e8c859e539fe</sv:value></sv:p
roperty><sv:property sv:name="jcr:created"
sv:type="Date"><sv:value>2014-10-01T11:24:59.194+02:00</sv:value></sv:property><
sv:property sv:name="dc:description-de" sv:type="String"
sv:multiple="true"><sv:value>aosduzoi</sv:value></sv:property><sv:property
sv:name="jcr:lastModified"
sv:type="Date"><sv:value>2014-10-01T11:24:59.194+02:00</sv:value></sv:property><
sv:property sv:name="dc:language" sv:type="String"
sv:multiple="true"><sv:value>ger</sv:value></sv:property><sv:property
sv:name="jcr:lastModifiedBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property><sv:property
sv:name="jcr:createdBy"
sv:type="String"><sv:value>bypassAdmin</sv:value></sv:property></sv:node></sv:no
de>
Original issue reported on code.google.com by [email protected]
on 1 Oct 2014 at 12:05
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 [email protected]
on 22 Jun 2012 at 9:09
Hi,
I tracked down a javascript syntax error in my application to x2js.
FIrefox 34.0.5
https://x2js.googlecode.com/hg/demo.html
- syntax error ... demo.html:1
- the highlighted line in code is line 1:demo.html - <!doctype html>
The error is unhelpful and seems to point generally to a broken <script> tag.
This is not the case in my application nor apparently on the demo page.
The demo page still works as expected but I feel it is worth taking note of.
I've searched project issues (keywords: syntax error firefox/firebug) but I
don't see that this error has been previously reported.
Thanks for the project, it has made life easier having such a good library for
converting xml<->json.
Kind regards,
Darryl
Original issue reported on code.google.com by darryljcousins
on 18 Dec 2014 at 2:06
What steps will reproduce the problem?
1. read in feed that has ampersands within data
2. execute jsfiddle with feed
3. parse error on execution
What is the expected output? What do you see instead?
JSON with correctly escaped ampersand to be able to replicate XML feed which
includes many ampersands within data.
See instead a parse error.
What version of the product are you using? On what operating system and
browser version?
x2js 1.1.2
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 16 Oct 2013 at 11:00
What steps will reproduce the problem?
1. Install node.js
2. Install xmldom with this command:
npm install xmldom
3. use the following code:
var window={};
var DOMParser = require('xmldom').DOMParser;
window.DOMParser=DOMParser;
//do the usual x2js stuff
What is the expected output? What do you see instead?
I expect normal functionality but it blows up under server-side javascript.
What version of the product are you using? On what operating system?
node.js 0.8.12 on windows 7.
Please provide any additional information below.
Change the code from this (start at line 233):
if (window.DOMParser) {
var parser=new DOMParser();
xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
}
to this:
if (window.DOMParser) {
var parser=new window.DOMParser();
xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
}
Original issue reported on code.google.com by [email protected]
on 18 Oct 2012 at 1:54
Cut some slightly overcomplicated code
Original issue reported on code.google.com by [email protected]
on 10 May 2013 at 9:13
Attachments:
What steps will reproduce the problem?
When I try to open the x2js demo at http://jsfiddle.net/abdmob/gtLBx/15/, I'm
presented with a page that shows two empty text areas -- one labelled "XML",
one
labelled "JSON".
What is the expected output? What do you see instead?
I expect the contents of the "XML" window to show a sample XML string per the
code:
$("#xmlArea").val("<root><child><textNode>First &
Child</textNode></child><child><textNode>Second
Child</textNode></child><testAttrs attr1='attr1Value'/></root>");
Instead, the text area is empty.
What version of the product are you using? On what operating system and
browser version?
Windows 7, same results in both Chrome and IE.
Please provide any additional information below.
I notice that if I run the Chrome developer console, (F12) there's an uncaught
exception when loading the app.
The text of the error is:
Uncaught TypeError: url.indexOf is not a function
This appears in the "jquery-git.js" tab.
Original issue reported on code.google.com by [email protected]
on 20 May 2015 at 9:02
This patch adds the option to use double quotations for XML attribute values.
Original issue reported on code.google.com by [email protected]
on 6 Aug 2014 at 8:40
Attachments:
Hi, it's me again...
What steps will reproduce the problem?
1. opening demo.html
2.
3.
What is the expected output? What do you see instead?
XML area contains demo xml, JSON area is empty.
Console log:
SCRIPT5022: DOM Exception: SYNTAX_ERR (12)
xml2json.js, line 483 character 4
XML5619: Incorrect document syntax.
, line 1 character 1
What version of the product are you using? On what operating system and
browser version?
1.1.4, Win7, IE9
Please provide any additional information below.
Funny that this works in IE8 but fails in IE9
Original issue reported on code.google.com by [email protected]
on 10 Jan 2014 at 4:03
Attachments:
Hello,
we were in need to add custom prefix to a an xml attributes (instead of "_").
Here is the patch.
x2js version: v1.0.11
--
Ro
Original issue reported on code.google.com by [email protected]
on 12 Mar 2013 at 2:46
Attachments:
Let's say we have an object:
{
$$hashKey: 3,
element1: "something",
element2: "something else"
}
Then, when we pump this through `x2js.json2xml_str()`, it will fail. The
`$$hashKey` is an invalid name.
It would be nice to configure this to either fail or ignore those pesty
properties... or have a service to strip out invalid properties.
Would this idea be something you'd consider?
Original issue reported on code.google.com by [email protected]
on 27 Jan 2015 at 7:43
What steps will reproduce the problem?
1. Make unsuccessful AJAX call
2. Feed resulting 'undefined' into x2js (expecting xml)
What is the expected output? What do you see instead?
Expect x2js to do nothing, get cryptic error
What version of the product are you using? On what operating system and
browser version?
v 1.0.11
Firefox, Chrome
Please provide any additional information below.
Suggest to add in xml2json.js, line 249:
if (xmlDocStr === undefined) {
xmlDocStr = "";
}
Original issue reported on code.google.com by [email protected]
on 25 Jul 2013 at 9:23
What steps will reproduce the problem?
1. Create an object as following:
var ev = {
allDay: true,
editable: undefined,
end: undefined,
id: undefined,
start: 1351551600,
timeZoneOffset: 1,
title: "eventSource2"
}
2. Call the function json2xml_str(ev)
What is the expected output? What do you see instead?
it would or create no xml for the undefined, or empty
What version of the product are you using? On what operating system?
1.0.8, on Chrome
Please provide any additional information below.
I adapted line 236
if(subObj!=null && subObj instanceof Object && subObj!=undefined) {
and line 247
else if ( subObj != undefined ) {
Original issue reported on code.google.com by [email protected]
on 27 Nov 2012 at 11:04
This results in xml-files that looks ugly like this:
...
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
...
The only characters that has to be escaped are: <, &, >, ", '
Also ' should be replaced with '
See:
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#En
tities_representing_special_characters_in_XHTML
Replacement code:
function escapeXmlChars(str) {
if(typeof(str) == "string")
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
else
return str;
}
Also the unescapeXmlChars should handle any escaped character (unicode and
named) and not a small predefined set.
Original issue reported on code.google.com by [email protected]
on 5 Feb 2015 at 1:34
I'd like to have no prefix set by the parsing at all. The issue comes in from:
config.attributePrefix = config.attributePrefix || "_";
When passing in an empty string (attributePrefix: ""), this evaluates to false,
and the underscore is set as the prefix.
Original issue reported on code.google.com by [email protected]
on 7 Oct 2014 at 8:29
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.