OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] What's the point of customizing element tags?

[ Lists Home | Date Index | Thread Index ]

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@expway.fr>
Research Scientist, Expway      http://expway.com/
7FC0 6F5F D864 EFB8 08CE  8E74 58E6 D5DB 4889 2488





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS