Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / June 2005



Tip: Looking for answers? Try searching our database.

Accessing XML nodes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bart_Sportpaleis - 21 Jun 2005 15:34 GMT
Suppose this your XML:

<content>
   <author>
       <book>
            <title>this is the title</title>
            <description>book description</description>
       <book>
   </author>
</content>

How can I easily retrieve the title using the nodeNames? I don't like this way
of accessing:

this.childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue

Just because it's confusing. I would like a notation like this or something
similar:

content.author.book.title.nodeValue()

Is this possible? Grtz, Bart
LuigiL - 21 Jun 2005 22:38 GMT
Wouldn't that be comfortable. Unfortunately, no. But, you can define an object
and turn the nodes into properties of that object. Than you would have access
with myObject.title
Otherwise you could extend the XMLNode class but that might be even more
confusing.
Another option: if you don't like working with this syntax, consider the
XMLConnector component along with a DataHolder or DataSet. This gives you the
option of binding the XML tree visually and you don't have to work with the
childNodes syntax.
chris.davis - 24 Jun 2005 05:52 GMT
Bart_Sportpaleis,

Try this freeware XPath implementation for ActionScript:  
http://www.xfactorstudio.com

This library mimics XPath which makes traversing XML structures much easier.  
You can refer to paths like directories (content/author/book/title) instead of
the awkward approach like you've shown.  After I got fed up with the
"recommended" way to do this, I searched a while and found this and have been
much happier with it.

Hope this helps,

-Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.