Hello,
Has anyone found out why the parsing of a XML document fails when
using a node's name (but succeeds when using an index [n]) when there
is a namespace definition in the node..?
var xml:XML =
foo
bargood/bar
bar xmlns=http://model.gts.com;bad/bar
/foo
trace(xml..bar); //good
good
Returns both nodes if the namespace declaration is removed:
bargood/bar
barbad/bar
Can anyone tell me why? Suggestions..?
Thanks,
Paul
--- In flexcoders@yahoogroups.com, Shailesh Mangal
[EMAIL PROTECTED] wrote:
I figured this out. Here is what worked for me.
var res:XML = event.result as XML;
var ns:Namespace = res.namespace();
var imgName:String = res..ns::marketValue;
:: operator is the key.
This works well for the defualt namespace. I still havent figured how
to access an element whose namespace different then the default
nameSpace and is not known.
-Shailesh
--- In flexcoders@yahoogroups.com, Tracy Spratt tspratt@ wrote:
Uisn the index will work but it would be much better to figure out the
namespace problem. I am currently working on an example to learn
about
namespaces myself.
Ben Clinkinbeard has posted on this issue often and he has some
examples
and discussion on his Blog. I plan to head over there and start
studying when I have a bit of spare time.
Tracy
From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On
Behalf Of Ben Marchbanks
Sent: Wednesday, January 03, 2007 8:54 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] problem in parsing xml return by
HTTPservice,
could it be namespace issue
You try what I used to solve the same kind of problem
event.result.record[0].myFieldName
where my XML looks something like this
records
record
myFeldNamemyValue/myFieldName
/record
/records
Thanks to Tracy Spratt for revealing access to the
XML more directly via event.result !
Shailesh Mangal wrote:
Hi all,
Here is the xml I get back from my HTTPService call
res:message source=web action=coveragemap id=123
xmlns:res=http://response.coveragemap http://response.coveragemap
com:statusCode xmlns:com=common0/com:statusCode
com:statusDesc xmlns:com=commonSuccess/com:statusDesc
res:marketValueSanFrancisco_CA/res:marketValue
/res:message
but when I try to use .. operator for marketValue node, I get null
object back. Any suggestions. I tried use namespace also, didnt
help.
HTTPService Call
mx:HTTPService id=xmlPoster2 url={loc + 'coveragemap'}
method=POST resultFormat=e4x contentType=application/xml
result=showMap(event)/
public function showMap(event:ResultEvent):void{
trace(event.result);
var res:XML = event.result..marketValue as XML;
var imgName:String = res.toString();
imgSrc = assets/img/ + imgName;
coverageMapBox.setVisible(Boolean(true));
}