Can You ReUse XQL Query References

Lets say that I had an XML document with a structure a bit like this:














I would use XQL statement ‘//block’ to retrieve an XMLNodeList that lists all of the instances of ‘block’ tag. But what if I had already made a call in my code to access all block tags and now I want all attribute tags within block tags. So how would I efficiently be able to reuse my reference with the XQL call I made to ‘//block’ earlier.

To put the question simply, I would like to know if there is a special way to reuse XQL references and if even if you have to make a full query every time you call XQL what is the suggested way to references to a particular item from a list you have.

Will I need to maybe switch up the XML code so that each block has an ID (which I can use to identify which block I have already queried). For example:














Thanks

You can loop through the Items in the nodelist and run an XQL on each one individually. This is really the only way to preserve any path information. If you do a global XQL on Attribute, you’d get a nodelist of attribute nodes, but you’d have no way of knowing which Block each one belonged to.

To get the nodes that are a direct child just use the name. This is the case in your example, after “//block” use “attribute”. If the attribute nodes could be at deeper levels use “.//attribute”.

summary //attribute find all attributes starting from root attribute find direct children from current node ./attribute same as above .//attribute find any descendants from current node

This may help
http://search.cpan.org/~enno/libxml-enno-1.02/lib/XML/XQL/Tutorial.pod#Context

[quote=296225:@Will Shank]To get the nodes that are a direct child just use the name. This is the case in your example, after “//block” use “attribute”. If the attribute nodes could be at deeper levels use “.//attribute”.

summary //attribute find all attributes starting from root attribute find direct children from current node ./attribute same as above .//attribute find any descendants from current node

This may help
http://search.cpan.org/~enno/libxml-enno-1.02/lib/XML/XQL/Tutorial.pod#Context[/quote]
Thanks