I have a Word 2003 XML document that I am trying to search for certain elements in. I have been able to do simple XPath queries to find single elements, but I am having difficulty coming up with a query to search between two elements:
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText> DOCPROPERTY EvidenceBase \* MERGEFORMAT </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate"/>
</w:r>
<w:r>
<w:t>EvidenceBase</w:t>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
I am searching for the above XML, that has a w:r with a w:fldChar in it which has an attribute of w:fldCharType with value of “begin”. It should return every element until it hits a w:r with a w:fldChar in it which has an attribute of w:fldCharType with value of “end”.
Is this possible?
Mind that the prefix
wwould need to be bound to the proper namespace for the XPath expression namespace context. How this is done depends on how you use the XPath (XSLT, Java, C#…).Also, this would be more complex if there’s multiple, possibly nested “begin” and “end” markers.