Reputation: 2561
I can't seem to grab this specific node.
<w:body>
<w:p wsp:rsidR="00D12EE7" wsp:rsidRDefault="00F86B09">
<w:fldSimple w:instr=" MERGEFIELD GAS_REAFCity ">
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:t>«GAS_REAFCity»</w:t>
</w:r>
</w:fldSimple>
</w:p>
</w:body>
I have tried can get as close as //w:p/w:fldSimple but how do i select w:instr=" MERGEFIELD GAS_REAFCity ".
Thanks Appreciate any help!!
Upvotes: 1
Views: 268
Reputation: 21
Your XPath will grab the element node, but you want the attribute node. Your xpath will need to be something like //w:p/w:fldSimple/@w:instr
. depending on what your using to evaluate the xpath you could probably use something like myAttr.getText(), alternatively, you can use string(//w:p/w:fldSimple/@w:instr)
.
I notice that your XPath is relative, is this intentional? Lastly, there are many excellent frameworks for processing DOMs and XPaths, and I know at least Dom4J will allow you to programmatically walk a Dom tree and then you can query the XPath that would access that node.
I found the following tutorial useful when starting out
Hope this helps
Upvotes: 2
Reputation: 12359
Don't attributes use the @ syntax, so you'd select @w:instr ?
//w:p/w:fldSimple[@w:instr=" MERGEFIELD GAS_REAFCity "]
Upvotes: 3