Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search


From: bry:itnisk at: 20-Mar-2003 14:11

><a> > <b/> > <c> > <d/> > <e/> > <d/> > </c> > </a>
Needs to be more like: test: to xml! { <a att="some text here"> <b/> <c> text <d att="d att"/> <e/> <d/> text </c> </a> } according to xpath 1.0 which has it's own datatypes for this kind of thing: there is a root element / / has one child a, known as the document element a has one attribute and two child nodes, one of these elements b is empty, c has children. c has two text nodes, and one element node d which has an attribute the value of which equals d att and an empty element e. various xpaths: xpath1 = "/" returns the xml instance from the document element, i.e a xpath2 = "/a/@att" returns the att attribute of a xpath3 = "/a[@att/d]" returns d as a direct child of a, which there isn't any of. Xpath4 = "//d" returns any d in the document Xpath5 = "//d[@att='d att'][e and not(text())]" returns any d in the document that has an attribute att the value of which equals d att, has a child element e and does not have any text() nodes. Xpath6 = "//d[parent::c]" returns any d which has a parent node c And so forth. This could have been complicated by using sibling examples and namespaces but this is a good start. Xpath is in my opinion pretty simple and an example of a highly successful way of working with xml data, it is used in various dom implementations and streaming apis, as well as xsl-t. There are approved mechanisms for extending xpath dependant on its implementation environment. Dependant on implementation one can as a general rule follow an xpath to a position within the xml instance and from there use a different xpath to navigate to another position relative to current context. A representation of xml as blocks and using rebols block navigating syntax, nor the basic syntax for doing picks etc. does not seem to come close, however this could just be caused by my seeing things which for me are especially easy with xpath over xml due to my expertise as being difficult with rebol over xml as a block due to my ineptitude. Any clarification on how one would do these things would thus be much appreciated.