Posted by Ramon Ribσ on 11/26/06 10:30
package require tdom
set doc [dom parse {<?xml version="1.0" encoding="utf-8" ?><trivia><entry
id="1101"
triviaID="233" question="Who wrote "Trilogy of Knowledge"?"
answerID="1" correctAnswerID="1" answer="Believer"
expDate="1139634000"></entry><entry id="1102" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="2"
correctAnswerID="1" answer="Saviour Machine"
expDate="1139634000"></entry><entry id="1103" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="3"
correctAnswerID="1" answer="Seventh Avenue"
expDate="1139634000"></entry><entry id="1104" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="4"
correctAnswerID="1" answer="Inevitable End"
expDate="1139634000"></entry><entry id="1105" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="5"
correctAnswerID="1" answer="No such song existed"
expDate="1139634000"></entry></trivia>}]
set res ""
foreach domNode [$doc selectNodes ./*/*/attribute::*] {
eval lappend res $domNode
}
puts $res
--->
id 1101 triviaID 233 question {Who wrote "Trilogy of Knowledge"?} answerID
1 correctAnswerID 1 answer Believer expDate 1139634000 id 1102 triviaID
233 question {Who wrote "Trilogy of Knowledge"?} answerID 2
correctAnswerID 1 answer {Saviour Machine} expDate 1139634000 id 1103
triviaID 233 question {Who wrote "Trilogy of Knowledge"?} answerID 3
correctAnswerID 1 answer {Seventh Avenue} expDate 1139634000 id 1104
triviaID 233 question {Who wrote "Trilogy of Knowledge"?} answerID 4
correctAnswerID 1 answer {Inevitable End} expDate 1139634000 id 1105
triviaID 233 question {Who wrote "Trilogy of Knowledge"?} answerID 5
correctAnswerID 1 answer {No such song existed} expDate 1139634000
Ramon RibΓ³
En Sat, 25 Nov 2006 19:53:21 +0100, comp.lang.tcl
<phillip.s.powell@gmail.com> escribiΓ³:
of parsing this:
<?xml version="1.0" encoding="utf-8" ?><trivia><entry id="1101"
triviaID="233" question="Who wrote "Trilogy of Knowledge"?"
answerID="1" correctAnswerID="1" answer="Believer"
expDate="1139634000"></entry><entry id="1102" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="2"
correctAnswerID="1" answer="Saviour Machine"
expDate="1139634000"></entry><entry id="1103" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="3"
correctAnswerID="1" answer="Seventh Avenue"
expDate="1139634000"></entry><entry id="1104" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="4"
correctAnswerID="1" answer="Inevitable End"
expDate="1139634000"></entry><entry id="1105" triviaID="233"
question="Who wrote "Trilogy of Knowledge"?" answerID="5"
correctAnswerID="1" answer="No such song existed"
expDate="1139634000"></entry></trivia>
Into this:
Navigation:
[Reply to this message]
|