473,549 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

<QuestionResult s>
<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="choiceCou nt"
select="//QuestionResults/Question[@QuestionID=$qi d][Answer=$matchTe xt]/Answer/@AnswerCount"/>

<xsl:choose>
<xsl:when test="$choiceCo unt 0">
<xsl:value-of select="$choice Count" />
</xsl:when>
<xsl:otherwis e>-</xsl:otherwise>
</xsl:choose>

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

Feb 19 '07 #1
2 3598
* Chuck P wrote in microsoft.publi c.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

<QuestionResult s>
<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="choiceCou nt"
select="//QuestionResults/Question[@QuestionID=$qi d][Answer=$matchTe xt]/Answer/@AnswerCount"/>

<xsl:choose>
<xsl:when test="$choiceCo unt 0">
<xsl:value-of select="$choice Count" />
</xsl:when>
<xsl:otherwis e>-</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****@h oehrmann.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
5961
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 doc=parseString(xmlstr) nodeList = xml.xpath.Evaluate("/p:root/p:child/text()", doc)
0
3473
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 trying to extract the stock information after having downloaded the HTML and converted to XML (well-formed HTML) using XSL and XPATH and am unable. ...
2
5044
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 example, given the XHTML: <html> <body>
7
16635
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
2519
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 of the currently matched element in the template, so that XPath expressions inside would be relative to that node? Specifically, I want to do...
3
3027
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 like bla bal <center>bla</center><img> alblalba
1
1069
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
1155
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 would point to either of the following -- depending on which one had the attribute name (which will always be unique). //Base/Station/Measure...
5
1583
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 the corresponding answers? I don't want to retrieve all the Answer and VoteAnswers nodes <xsl:for-each select="NSurveyVoter/Voter/Question/Answer">...
0
7526
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7457
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7965
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
771
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.