C# - XPath for XMLDataSource?

  • Thread starter Darth Continent
  • Start date
D

Darth Continent

Say you have an XML file that looks like this:

<KW>
<Subjects SubjectID="00100" SubjectDescription="ABORTION"/>
<Subjects SubjectID="00010" SubjectDescription="ABUSE * ADULT *
INVESTIGATION"/>
<Subjects SubjectID="06450" SubjectDescription="ABUSE * CHILD ABUSE *
COUNSELING"/>
</KW>

I'm trying to configure the XPath property of a C# XMLDataSource
object so that I can grab the rows in this XML file for which the
SubjectDescription contains a given search criteria. For example, if
the criteria were "ABUSE", the last two rows of the XML would be
returned as a result set.

What exact XPath syntax would perform this query?
 
A

Arne Vajhøj

Darth said:
Say you have an XML file that looks like this:

<KW>
<Subjects SubjectID="00100" SubjectDescription="ABORTION"/>
<Subjects SubjectID="00010" SubjectDescription="ABUSE * ADULT *
INVESTIGATION"/>
<Subjects SubjectID="06450" SubjectDescription="ABUSE * CHILD ABUSE *
COUNSELING"/>
</KW>

I'm trying to configure the XPath property of a C# XMLDataSource
object so that I can grab the rows in this XML file for which the
SubjectDescription contains a given search criteria. For example, if
the criteria were "ABUSE", the last two rows of the XML would be
returned as a result set.

What exact XPath syntax would perform this query?

Try:

"//KW/Subjects[@SubjectDescription='foobar']"

Arne
 
M

Martin Honnen

Darth said:
Say you have an XML file that looks like this:

<KW>
<Subjects SubjectID="00100" SubjectDescription="ABORTION"/>
<Subjects SubjectID="00010" SubjectDescription="ABUSE * ADULT *
INVESTIGATION"/>
<Subjects SubjectID="06450" SubjectDescription="ABUSE * CHILD ABUSE *
COUNSELING"/>
</KW>

I'm trying to configure the XPath property of a C# XMLDataSource
object so that I can grab the rows in this XML file for which the
SubjectDescription contains a given search criteria. For example, if
the criteria were "ABUSE", the last two rows of the XML would be
returned as a result set.

What exact XPath syntax would perform this query?

/KW/Subjects[contains(@SubjectDescription, 'ABUSE')]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top