[Home] [By Thread] [By Date] [Recent Entries]


Jeffrey Fitzgerald wrote:
> But what is the point of custom naming xml elements when they are 
> not accessed in an OOP manner?
>     Here is what I mean:
> 
>     <newbie>
>         <question>
>                       <whatsUp>Whats the point</whatsUp>
>         </question>
>     </newbie>
>     
>     My understanding is that you don't access the contents using syntax 
> like: newbie.question.whatsUp.value, but rather an obscure
> childNodes[0].childNodes[0].childNodes[0].nodeValue (not even sure if 
> that is right).

You are just quoting an API, in this case the DOM, and unless you use a language 
that equates NodeLists to arrays, you'll need to replace [0] with .item(0). In 
fact, using the first item in the childNodes here is probably going to bite you 
very hard since for newbie and question, the first node will be a text node 
containing whitespace.

Using other APIs you could get what you want. Both Perl and Python have APIs 
that will access the above as root.newbie.question.whatsUp, or something locally 
similar.

You could also use XPath: /newbie/question/whatsUp.

-- 
Robin Berjon <robin.berjon@e...>
Research Scientist, Expway      http://expway.com/
7FC0 6F5F D864 EFB8 08CE  8E74 58E6 D5DB 4889 2488


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member