As I understand it, the toXMLString() method of an e4x object should preserve a valid xml snippet?
Eg. This should work
var o2 = XML( o1.toXMLString() );
However, when I try the following ( 1.9.2a2pre ) I get an "invalid XML namespace error"
The XML:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<NS1:soapHeader xmlns:NS1="urn:types:soapheader">false</NS1:soapHeader>
</soap:Header>
</soap:Envelope>
The JS:
var env = XML( [the string above] );
var nodes = env..*;
alert( nodes[ 1 ].inScopeNamespaces() ); // alerts: http://schemas.xmlsoap.org/soap/envelope/
var xmlString = nodes[ 1 ].toXMLString();
alert( xmlString ); // alerts <soap:Header> node string
var e4x = XML( xmlString ); // Error invalid XML namespace soap
This fails even though the namespace is returned as in scope for this object. The only workaround I have is to loop through and redeclare the
in scope namespaces of the root object being exported.
Could someone sanity check for me before I submit a bug
Cheers,
Neil
Sure seems like a bug; toXMLString specifies that [[InScopeNamespaces]]
should be serialized on the object.
That said, this is a JS engine bug, not a Gecko XML bug.
-Boris
Hey Boris,
Cool thanks that's what I read the spec as.
> That said, this is a JS engine bug, not a Gecko XML bug.
Yes apologies I wasn't sure which NG to post E4x questions to - XML or JS.
Cheers,
N