Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2007

Tip: Looking for answers? Try searching our database.

xpath match text question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chuck P - 19 Feb 2007 05:00 GMT
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.
Bjoern Hoehrmann - 19 Feb 2007 05:48 GMT
* 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
[quoted text clipped - 25 lines]
>
>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.
Signature

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/

WenYuan Wang - 22 Feb 2007 12:21 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.