comp.lang.tcl
[Top] [All Lists]

Re: tdom - not understanding "nextSibling"

Subject: Re: tdom - not understanding "nextSibling"
From: Christian Nassau
Date: Thu, 29 May 2008 23:13:51 +0200
Newsgroups: comp.lang.tcl


chedderslam wrote:
I have a simple xml document:
<recordset>
 <division name="myname">
  <coe_division_name>MISSISSIPPI VALLEY</coe_division_name>
  <division_abbreviation>MVD</division_abbreviation>
 </division>
</recordset>

Whe I am parsing it and get to the node:
<coe_division_name>MISSISSIPPI VALLEY</coe_division_name>
I am running this code:
set myvar [$doc nextSibling]
however, the result is blank.

My guess is that your node is the "MISSISSIPPI VALLEY" text node, not the "coe_division_name" that you want. Could also be that your "doc" variable contains the document, not the selected node.

Anyway, the following code seems to do what you want:

dom parse {
<recordset>
 <division name="myname">
  <coe_division_name>MISSISSIPPI VALLEY</coe_division_name>
  <division_abbreviation>MVD</division_abbreviation>
 </division>
</recordset>
} doc

set nd [$doc selectNodes .//coe_division_name]

puts [$nd asXML]
puts [$nd nextSibling]
puts [[$nd nextSibling] asXML]

HTH,

--
 => Christian Nassau, http://www.nullhomotopie.de



<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy