473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

xpath match text question

I am trying to retrieve the @AnswerCount Attribute
for the @QuestionID=1 AND the Answer element text =3

I successfully can pass the variables QuestionID and Answer but can't pull
out the
@AnswerCount

<QuestionResults>
<Question QuestionID="1">
<Answer AnswerCount="1">1</Answer>
<Answer AnswerCount="5">3</Answer>
<Answer AnswerCount="1">4</Answer>
<Answer AnswerCount="1">N/A</Answer>
</Question>
<Question QuestionID="2">
......

I was unsucessfully trying:
<xsl:variable name="choiceCount"
select="//QuestionResults/Question[@QuestionID=$qid][Answer=$matchText]/Answer/@AnswerCount"/>

<xsl:choose>
<xsl:when test="$choiceCount 0">
<xsl:value-of select="$choiceCount" />
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>

I always get 1 for the $choiceCount when the @QuestionID is found.

Feb 19 '07 #1
2 3591
* Chuck P wrote in microsoft.public.dotnet.xml:
>I am trying to retrieve the @AnswerCount Attribute
for the @QuestionID=1 AND the Answer element text =3

I successfully can pass the variables QuestionID and Answer but can't pull
out the
@AnswerCount

<QuestionResults>
<Question QuestionID="1">
<Answer AnswerCount="1">1</Answer>
<Answer AnswerCount="5">3</Answer>
<Answer AnswerCount="1">4</Answer>
<Answer AnswerCount="1">N/A</Answer>
</Question>
<Question QuestionID="2">
......

I was unsucessfully trying:
<xsl:variable name="choiceCount"
select="//QuestionResults/Question[@QuestionID=$qid][Answer=$matchText]/Answer/@AnswerCount"/>

<xsl:choose>
<xsl:when test="$choiceCount 0">
<xsl:value-of select="$choiceCount" />
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>

I always get 1 for the $choiceCount when the @QuestionID is found.
That's because the right Answer is not in your path, you just check
whether there is a right Answer. Put the predicate after the Answer,
..../Answer[ . = $matchText ]/@AnswerCount.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Feb 19 '07 #2
Hi Chuck,

Just want to check if the issue has been resolved.
Please feel free to let me know if there is anything we can help with.

Have a great day.
Sincerely,
Wen Yuan

Feb 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
0
by: Michael Fork | last post by:
Note: I pasted the code the attachments as plain text after the message (I wasn't able to post it with an attachment...) Attached are the XSL and XML files that I am having problems with. I am...
2
by: ahogue at theory dot lcs dot mit dot edu | last post by:
Hello - Is there any way to match complex subtree patterns with XPath? The functions I see all seem to match along a single path from root to leaf. I would like to match full subtrees. For...
7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
5
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
3
by: Tjerk Wolterink | last post by:
Hello i have xml code like this: <page:page xmlns:page="namespacefor page"> <page:section> <page:header> <b>Hello</b>There </page:header> <page:content> --- HTML CODE like: <i>Y</i>es i...
1
by: bjam | last post by:
Hi, a quick basic question here on XPATH if I have the following data <X> <X1>TEST</X1> <Z> <Z1>Item 1</Z1> <Z2>Item 2</Z2> <Z3>Item 3</Z3>
1
by: Kathy Burke | last post by:
I'm trying to figure out how to do an xpath that simply looks for a unique attribute name. For example, select the node where the name attribute is "test1"...regardless of which element. It...
5
by: Patrick.O.Ige | last post by:
I have an xml and i'm trying to loop each node... When i do FOR EACH i seem not to get my desired result I want to loop through and get only the values that matches the question i specified with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.