Can you search through XML for a specific node value?

I have an xml file that I am picking through to dump information into Notes documents. Now I need to search through the xml for a particular value and then find the node that that value appears in. Is this possible?

For instance, I have 10 person nodes that hold name, age and a unique number.

I want to use the unique number string to find the person node that is it contained in.

Can anyone help? Or is this not possible?

Cheers in advance,

Katherine

Subject: Can you search through XML for a specific node value?

How are you “picking through” the XML files? Are you using an XSL file run via a NotesXSLTransformer?

If so, you could do something like this in your XSL:

<xsl:template match=“person”>

<xsl:if test="uniqueNumber='40'">

	<document form="myNotesForm">

		<item name="UniqueNumber">

			<text>

				<xsl:value-of select="uniqueNumber"/>

			</text>

		</item>

		<item name="personName">

			<text>

				<xsl:value-of select="personName"/>

			</text>

		</item>

		<xsl:apply-templates/>

	</document>

	</xsl:if>

</xsl:template>

This will create Notes documents for all person elements that contain the unique number string you specify, and create fields on the document for uniqueNumber and personName.

Subject: Can you search through XML for a specific node value?

One thing you could do here is build a collection of all elements and check the value in each one until you find the one you want. Then obtain the id or name attribute of that element. You could then set a new object to this element or do any other processing on it that you require.

Of course, Esther’s suggestion for using XSLT would be more efficient, particularily if you have a large number of Nodes to process.