-
XML parsing failed
Hi,
If I use the following XML it does not output anything. Please help me to find what is the issue.
PHP Code:
var xml:XML = <xml>
<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 http://www.imsglobal.org/xsd/imscp_v1p1.xsd http://www.imsglobal.org/xsd/imsmd_v1p2 http://www.imsglobal.org/xsd/imsmd_v1p2.xsd " identifier="Manifest7-CEC3D3-3201-DF8E-8F42-3CEED12F4197" version="IMS CP 1.1.4">
<text>Text</text>
</manifest>
</xml>;
trace(xml.manifest.text)
It does not output anything on screen. Any help is appreciated.
Bug? That's not a bug, that's a feature.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Coo
-
In playing with it, it looks like the xmlns attribute is screwing it up. Without that, it outputs "Text" as expected.
-
Senior Member
I am not sure how to get to it using the direct method because of several namespace declarations, but a simple way is this:
trace(xml.child(0).child(0));//trace is Text
- The right of the People to create Flash movies shall not be infringed. -
-
Solution
Actionscript Code:
var nsIMS:Namespace = new Namespace("http://www.imsglobal.org/xsd/imscp_v1p1");
// set the default ns to ims default xml namespace = nsIMS; var xml:XML = <xml> <manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 [url]http://www.imsglobal.org/xsd/imscp_v1p1.xsd[/url] [url]http://www.imsglobal.org/xsd/imsmd_v1p2[/url] [url]http://www.imsglobal.org/xsd/imsmd_v1p2.xsd[/url] " identifier="Manifest7-CEC3D3-3201-DF8E-8F42-3CEED12F4197" version="IMS CP 1.1.4"> <text>Text</text> </manifest> </xml>;
trace("ims def ns: ",xml.manifest.text);
// set the default ns to null when done
default xml namespace = null;
trace("null def ns: ", xml.manifest.text);
Bug? That's not a bug, that's a feature.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Coo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|