Not yet rated

Problem

I am trying to remove the ns2 namespace in an XML file. Ex: - <ns2:Networth schemaVersion="1.0" xmlns:ns2="http://namespace.yodlee.com/pfm/2009/Networth"> - <ns2:AssetDetails> - <ns2:AssetAccount link="https://mc1.alpha.yodlee.com/moneycenter/srest/tier1/v1.0/account/summary?itemAccountId=10122283&itemId=10097356"> <ns2:accountName>City Bank & Trust Company (CBTC)</ns2:accountName> - <ns2:balanceAmount> Is there a way to convert this XML by removing the ns2 namesspace in front of every XML tag? My network monitor in Flash Builder is unable to accept this file as a XML file, resulting in throwing up a error, "Body could not be parsed as valid XML".

Solution

Use the NameSpace class to access nodes starting with ns2: Take a look at this example for reference http://cookbooks.adobe.com/post_Parsing_XML_with_Namespaces-15266.html The XML example is missing a few nodes. You will have problems if you copy and paste it as is.

Detailed explanation

var ns2Namespace:NameSpace = new NameSpace("http://namespace.yodlee.com/pfm/2009/Networth");

This will give you access to all nodes that start with ns2, so something like myXML::ns2Namespace[0] will get you into the data.

Refer to the link above for an example using RSS feeds.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes