Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? TCC and XMLnodes/XMLxpath functions

Dec
238
2
(TCC 15.01.52 x64 Windows 7 [Version 6.1.7601] / TCC Build 52 Windows 7 Build 7601 Service Pack 1)

I've been looking over the "TCC and XML" section of the online help. I know almost nothing yet about Xpath and I'm trying to pick up whatever I can from the help. The example of "bookstore.xml" is given in the CHM (xml_in_take_command.htm).

The document element is <bookstore> and the elements read in the script example are <book> elements. The sample script gets a count of nodes via:

set b=%@XMLnodes[/bookstore]
The value of "%b" is 4. But if I add an XML comment just below the document element, then the value of "%b" becomes 5 -- since of course the XML comment is a node that must be counted, right? Then the script generates an error at the end of what's printed to the console, and a spurious line is printed:

Harry Potter costs only 29.99
Learning XML costs only 39.95
Day Watch costs only 14.99
Winston Churchill: An Autobiography costs only 49.99
TCMD: (XML) Line: 0; Char: 0 TCMD: (XML) Line: 0; Char: 0 Winston Churchil

l: An Autobiography costs only 49.99

So: what would be the way, via this variable function, to target the count of ONLY the <book> elements (thus ignoring anything that ISN'T one of those elements)? (Neither "/" alone nor "/bookstore/book" does the job — not when that XML comment (or for that matter any other element) is added.
 
Back
Top
[FOX] Ultimate Translator
Translate