[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What's the point of customizing element tags?


Re:  What's the point of customizing element tags?
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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.