October 02, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | :) |
October 02, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alexander Panek | Alexander Panek wrote:
> Kris wrote:
>> I know of another that is /insanely/ fast. Not public yet, but it royally kicks some 'enterprise' ass
>
> Even the not-so-insanely fast version kicks ass and essentially does exactly the same I am trying to achieve - damn. As Lars said on IRC, the XML market is flourish these days. ;P
Well, is there as fast s-expression parser yet for D? I bet that could be useful for people who know xml is a bit too verbose. :)
|
October 02, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote: > Alexander Panek wrote: > >> Kris wrote: >>> I know of another that is /insanely/ fast. Not public yet, but it royally >>> kicks some 'enterprise' ass >> Even the not-so-insanely fast version kicks ass and essentially does >> exactly the same I am trying to achieve - damn. As Lars said on IRC, the >> XML market is flourish these days. ;P > > Well, is there as fast s-expression parser yet for D? I bet that could be > useful for people who know xml is a bit too verbose. :) There's the dead dLisp project. http://www.dsource.org/projects/dlisp I would hope they at *least* got as far as parsing s-exps before abandoning the project. --bb |
October 02, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Hsu | Hi Brian,
So nice to see a /simple/ DOM ;)
Are you considering XPath query also?
- Kris
Brian Hsu Wrote:
> Hello, everybody
>
> I've wrote an simple XML DOM-like parser, because I could not found an appropriate one that more comprehensive.
>
> I think may be there are others seeking for an library which could retrieve information from XML file easily, so here is my pieces of work.
>
> SimpleXMLD is a library which inspired by PHP's SimpleXML functions, it cloud load XML file into memory and build a tree structure of it. It is suitable when you just want to quickly access an small XML file.
>
> For example, if you have following XML file:
> ------------------ test.xml ---------------------
> <root isRoot="true">
> <hello>text</hello>
> <node key1="1">node 1</node>
> <node key2="2">node 2</node>
> </root>
> --------------------------------------------------
>
> And you cloud use SimpleXMLD access them easily:
> --------------------------------------------------
> import SimpleXMLD.all;
> void main ()
> {
> // Just load XML from disk file an build an tree structure
> SimpleXML root = SimpleXML.loadFile ("test.xml");
>
> // Get node attribute
> char [] isRoot = root.attributes["isRoot"]; // Now isRoot="true"
>
> // Get node data of hello
> SimpleXML [] hello = root["hello"];
>
> // This will output "text"
> Stdout (hello[0].data);
>
> // Iterate over all child
> foreach (SimpleXML node; root) {
> char [] tagname = node.tag;
> char [] textdata = node.data;
> }
>
> // Iterate over all olny child named "node"
> foreach (SimpleXML node; root["node"]) {
> char [] tagname = node.tag;
> char [] textdata = node.data;
> }
> }
> --------------------------------------------------
>
> Currently I am waiting dsource approve hosting this project on it, so I only have API document instead of official website. But I tried make API documents comprehensive and clearly, although my English is not my native speaking language, so it may be look a little weired.
>
> The SimpleXMLD library download could be found at API documents too. (http://bone.twbbs.org.tw/SimpleXMLD)
>
> It is first time I wrote library for D, and in fact I'm not really familiar with XML standard, so this library may be buggy, and the design is not very pretty too, so any suggestion are welcome.
>
> --
> Brian Hsu
|
October 03, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to fumanchu | fumanchu Wrote:
> Are you considering XPath query also?
> - Kris
Yes, but I'm just starting reading some XPath tutorial, so it may take an while before I could implement it.
And there is also a high probabilities that I would just implement a subset of it instead of all operator of XPath query.
For Example:
// Access Select middle BBB element(s) :
BBB[position() = floor(last() div 2 + 0.5) or position() = ceiling(last() div 2 + 0.5) ] may not be implemented.
Because currently I think the goal of SimpleXMLD is let user easily access XML as a tree structure without having to much knowledge about so many standard, parsing method or jargon that they do not know.
So XPath in my current thought, it is just a way that user could easily access nodes in XML tree structure when they are already know the structure of XML tree in SimpleXMLD.
They could use query like '/AAA/BBB/CCC' to access third level child and //BBB to access all child named BBB instead of writing much D code to do lots of tedious things like search the whole tree for nodes that are named BBB.
Since it is very easy when you could get all BBB node in an array and calculate the middle of array index to get the middle BBB node, using above XPath query will not save much computation time or memory space(because all node object are already in system memory), but just an overhead for library to process the query.
--
Brian Hsu
|
October 03, 2007 Re: SimpleXMLD XML Parser 0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Hsu | Makes a lot of sense; thanks :) "Brian Hsu" <brianhsu.hsu@gmail.com> wrote in message news:fdv00n$1hp0$1@digitalmars.com... > fumanchu Wrote: > >> Are you considering XPath query also? >> - Kris > > Yes, but I'm just starting reading some XPath tutorial, so it may take an while before I could implement it. > > And there is also a high probabilities that I would just implement a subset of it instead of all operator of XPath query. > > For Example: > // Access Select middle BBB element(s) : > BBB[position() = floor(last() div 2 + 0.5) or position() = ceiling(last() > div 2 + 0.5) ] may not be implemented. > > Because currently I think the goal of SimpleXMLD is let user easily access XML as a tree structure without having to much knowledge about so many standard, parsing method or jargon that they do not know. > > So XPath in my current thought, it is just a way that user could easily access nodes in XML tree structure when they are already know the structure of XML tree in SimpleXMLD. > > They could use query like '/AAA/BBB/CCC' to access third level child and //BBB to access all child named BBB instead of writing much D code to do lots of tedious things like search the whole tree for nodes that are named BBB. > > Since it is very easy when you could get all BBB node in an array and calculate the middle of array index to get the middle BBB node, using above XPath query will not save much computation time or memory space(because all node object are already in system memory), but just an overhead for library to process the query. > > -- > Brian Hsu |
Copyright © 1999-2021 by the D Language Foundation