View Single Post
  #9  
Unread 05-10-2011, 10:19 PM
Digital_Utopia's Avatar
Digital_Utopia Digital_Utopia is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 207
I'm a bit late on updating this thread with the latest work accomplished last weekend, but this is the state of the project right now:

Basic parsing/navigation functionality is done. At its current state, the XML string will be parsed into a tree of Node objects, which could then be navigated via the standard childNodes property, in addition to displaying nodeValue,nodeName and nodeType.

So for instance, this works:

Code:
myXML = parse(testxml);
Turbine.Shell.WriteLine(myXML.childNodes[0].childNodes[1].nodeName);
--outputs: item
The goal for the next weekend is to polish up the class, so its behavior is as close as possible to the XML DOM standards set by the W3C, and as implemented by most browsers (i.e. not IE). The most important step is to tweak and refine the code for the parser so the resulting node tree is influenced by newlines. Right now if you took the following XML through the parser:

Code:
<classes>
     <class name="Burglar"/>
</classes>
You would access the class element by

Code:
--local myclasses=myXML.childnodes...
myClasses.childNodes[1].NodeName;
However, taking into account that tables in Lua are 1-based (instead of 0-based like most other scripting languages), accessing the class element actually should require doing this:

Code:
myClasses.childNodes[2].NodeName;
because in reality, thanks to the newlines in the XML document, what the parser should actually see is something like this:

Code:
(text node)
<classes>
     (text node)
     <class name="Burglar"/>
     (text node)
</classes>
(text node)
on the other hand, if the XML looked like this...

Code:
<classes><class name="Burglar"/></classes>
then the parser would see this:

Code:
(text node)
<classes>
     <class name="Burglar"/>
</classes>
(text node)
Now, is it really that big of a deal? Probably not. However, I think it would be easier for anybody who uses it, that has had experience with working with XML on the web, to automatically know how this XML class works, without having to read the docs just to see how this particular implementation differs.

Like I mentioned, CDATA and XML creation/modification will not be supported initially, nor will namespaces. if, for some reason, users have a need for namespaces, or CDATA in their projects, I will be glad to add it in. However, CDATA support will require a change in the characters used in those tags - because this:

Code:
<![CDATA[+22 Might]]>
will break the xml string.
__________________

Lord of the Rings Online
75 Fourohfour | 75 Artemedis | 60 Whiskeytango Foxtrot | 50 Mistah Boombastic | 56 Appetizer | 25 Aggromi
61 Onepointtwentyone Gigawatts


World of Warcraft
90 Downlo 85 Gravetaxi 85 Ümad 85 Artemedis 85 Guthuros
Reply With Quote