Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 19th, 2007, 05:15 AM
=?Utf-8?B?Q2h1Y2sgUA==?=
Guest
 
Posts: n/a
Default 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.

  #2  
Old February 19th, 2007, 05:55 AM
Bjoern Hoehrmann
Guest
 
Posts: n/a
Default Re: xpath match text question

* Chuck P wrote in microsoft.public.dotnet.xml:
Quote:
>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:bjoern@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/
  #3  
Old February 22nd, 2007, 12:35 PM
WenYuan Wang
Guest
 
Posts: n/a
Default RE: xpath match text question

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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles