![]() |
|
|
|
#1 |
|
Hi,
I would like to initialize a variable but need help selecting the appropriate node. How can I select the only anchor element of a section element,(anywhere in the document), whose only section_header element's text is equal to "Menus"? <chapter> <section/> <section/> <section> <anchor>3_Menus</anchor> <section_header>Menus</section_header> </section> <section/> </chapter> Variable value would equal "3_Menus". I've tried several expressions including, //section/anchor[parent::section_header/text() =" Menus"], but no luck so far. Thanks Jeff Higgins Jeff Higgins |
|
|
|
|
#2 |
|
Posts: n/a
|
> //section/anchor[parent::section_header/text() =" Menus"],
1) parent:: specifies an axis, not a step. Not what you're looking for. 2) If you want to test the entire text content of an element, you can do so directly. Explicitly using text() means you're looking for a single text node whose value matches the one you've specified. Doesn't make a difference in this case either way, but worth pointing out for future. 3) If you want to match "Menus", don't write " Menus" ... (I presume that was just a typo. Summary: Try either section/anchor[../section_header="Menus"] or section/anchor[../section_header/text()="Menus"] (I'd use the former.) -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry |
|
|
|
#3 |
|
Posts: n/a
|
Joe Kesselman wrote: >> //section/anchor[parent::section_header/text() =" Menus"], > > 1) parent:: specifies an axis, not a step. Not what you're looking for. axis - step - got it + more studies > > 2) If you want to test the entire text content of an element, you can do > so directly. Explicitly using text() means you're looking for a single > text node whose value matches the one you've specified. Doesn't make a > difference in this case either way, but worth pointing out for future. <A>This is some <b>BOLD</b>text.</A> - A/text()[2] = "text." ? I'll check it out. > > 3) If you want to match "Menus", don't write " Menus" ... (I presume that > was just a typo. Yes, in my stylesheet8-P > > Summary: Try either > section/anchor[../section_header="Menus"] > or > section/anchor[../section_header/text()="Menus"] > > (I'd use the former.) > Thanks Joe. Appreciate it. Jeff Higgins |
|