A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: XML parsing failed

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    27

    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

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    In playing with it, it looks like the xmlns attribute is screwing it up. Without that, it outputs "Text" as expected.

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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. -

  4. #4
    Junior Member
    Join Date
    Aug 2008
    Posts
    27
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center