Namespace in XML
Hi,
How should you deal with namespaces in XML? As soon as there is a namespace (and there is in the string I currently get...), I can't manage to read any data out from the XML object I put the string inside.
Here is a samle piece of code I've been trying around with:
var myString = '<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/MyTest/MyTest"><int>0</int> <int>0</int> <int>0</int></ArrayOfInt>'
var myStringNoNS = '<ArrayOfInt> <int>0</int> <int>0</int> <int>0</int></ArrayOfInt>'
var myXML = XML(myString);
var myXMLNoNs = XML(myStringNoNS);
$.writeln(myXML.children().length());
// 0
$.writeln(myXMLNoNs.children().length());
// 3
// Trying to remove the namespace part using the built-in method for it:
var myXML2 = myXML.removeNamespace(myXML.namespace());
$.writeln(myXML.namespace() == myXML2.namespace() );
// True... So the Namespace was not removed.
// Writing out namespace(): http://tempuri.org/MyTest/MyTest
My question is:
Primarily: how do I read the contents of the nodes as they exist in myXML
Or if that is not possible: How do I get rid of the namespace using a built-in function such as removeNamespace.
Of cource I could make some string replacements in the original xml string, or alter the incoming data... but that's not my question. That's more of a last way out.
Thanks,
Andreas
