Here's how I handle the messy SOAP and namespace returned from my web service application server: (I set the return format to e4x)
private function webServiceResultHandler(event:ResultEvent):void { var xmlResult:XMLList = event.result as XMLList; var xmlSource:String = xmlResult.toString(); //Strip namespace xmlSource = xmlSource.replace(/<[^!?]?[^>]+?>/g, removeNamspaces); xmlResult = XMLList(xmlSource); } public function removeNamspaces(...rest):String { rest[0] = rest[0].replace(/xmlns[^"]+\"[^"]+\"/g, ""); var attrs:Array = rest[0].match(/\"[^"]*\"/g); rest[0] = rest[0].replace(/\"[^"]*\"/g, "%attribute value%"); rest[0] = rest[0].replace(/(<\/?|\s)\w+\:/g, "$1"); while (rest[0].indexOf("%attribute value%") > 0) { rest[0] = rest[0].replace("%attribute value%", attrs.shift()); } return rest[0]; } --- In flexcoders@yahoogroups.com, Vaibhav Seth <vaibhav.s...@...> wrote: > > > Use regex and eliminate the namspaces from the root tag of the XML, check if > it works. > > <Root> > . > . > . > > </Root> > > Thanks, > Vaibhav Seth. > > > > > EMAILING FOR THE GREATER GOOD > Join me > > To: flexcoders@yahoogroups.com > From: lukevanderfl...@... > Date: Fri, 22 Jan 2010 03:04:05 +0000 > Subject: [flexcoders] How to parse xml with namespaces > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi. > > > > Here is a snippet of xml: > > It contains an element with a namespace (c:question) and several elements > without a namespace. > > If I get the whole thing as an XML object, how do I go about accessing all > the different fields. > > E.G. I need to access the c:question text or c:question subelements > > > > So: 1. c:question text: "This is a wine question" > > 2. c:question subelements: p.ul.li: "Penfolds Grange - no effect" or p: > "A bottle shop in a remote country pub sells five different bottled wines. > The publican increases the price of a bottle of Jacob's Creek core range by > 50 cents." > > 3. question attribute format: "radio" > > > > Ive tried setting a namespace for c and a default namespace but cannot > consistently access elements and values from both namespaces. > > > > Id love your help.. > > Thanks. > > Kr. > > Luke. > > > > ===================== > > <?xml version=\"1.0\" encoding=\"UTF-8\"?> > > <c:question xmlns=\"http://www.w3.org/1999/xhtml\" > xmlns:c=\"http://www.eddygordon.com/namespaces/course\">This is a wine > question > > <p>A bottle shop in a remote country pub sells five different bottled wines. > The publican increases the price of a bottle of Jacob's Creek core range by > 50 cents. > > </p> > > <p>Assuming that the prices of the other wines do not change, the Jacob's > Creek price increase is likely to affect sales of the other products as > follows: > > </p> > > <p> > > <ul> > > <li>Penfolds Grange - no effect; > > </li> > > <li>Wyndham Estate Bin Range - the Wyndham Estate products are slightly > more expensive but the price increase has narrowed the gap so a slight > increase can be expected; > > </li> > > <li>Lindemans Bin Range - large increase in sales as this is a direct > competitor; > > </li> > > <li>Rosemount Split Label Range - large increase in sales as this is a > direct competitor > > </li> > > </ul></p><p>Based on this information, which wines are in the same market > as Jacob's Creek? > > </p> > > <question format=\"radio\" name=\"part1\"> > > <answer correct=\"true\">Lindemans Bin Range and Rosemount Split Label Range > are definitely in the same market and Wyndham Estate may be. > > </answer> > > <answer>Penfolds Grange is the only wine in the same market. > > </answer> > > <answer>Lindemans Bin Range and Rosemount Split Label Range are the only > wines in the same market. > > </answer> > > </question><p/> > > </c:question> > > ======================== >