From: Cameron L. <cl...@la...> - 2006-11-25 18:13:18
|
In article <jij...@la...>, I recommended: >In article <116...@h5...>, >comp.lang.tcl <phi...@gm...> wrote: > . > . > . >>> What exactly are you attempting to do? >> >>It's so easy. All I want to do is convert an XML file into a TCL list, >>that's it, just a TCL list: >> >>attr1 {val1} attr2 {val2} > . > . > . >Should we recommend a SAX or XQuery approach for this? >A SAX accumulator used to be canonical for something >this simple; I haven't worked with Rolf's XPath, but I >suspect it affords a one-liner that satisfies the >requirements. Oh, my; I *do* perceive deficiencies in TclXML documentation. I know that TclXML has had XPath since 2001. In particular, by 2004, Steve wrote about selectNodes in 3.0 <URL: http://talkaboutprogramming.com/group/comp.lang.tcl/messages/253140.html >. When I run puts [package require dom] set xml_image {<?xml version = "1.0" encoding = "UTF-8" ?> <via id="1" trivia_id="255" question="How much wood would a woodchuck chuck?" answer_id="1" answer="A lot" expDate="116494926"></via> } set doc [dom::parse $xml_image] set nodes [$doc selectNodes //via] on a recent Mac OS, though, I see 3.1 bad method "selectNodes": must be cget, configure, createElement, createDocumentFragment, createTextNode, createComment, createCDATASection, createProcessingInstruction, createAttribute, createEntity, createEntityReference, createDocTypeDecl, importNode, createElementNS, createAttributeNS, getElementsByTagNameNS, getElementsById, createEvent, getElementsByTagName, dtd, or schema So: what's it take to get TclXML to do XPath? |