-
Notifications
You must be signed in to change notification settings - Fork 27
Xpath Exercise 3 #369
Comments
@kes213 Aha! I think you're applying the repetition indicators from regular expressions to XPath. The Okay, we need to unpack how to get more than one of something in XPath. To do this, we need to find the paragraphs, first of all--so your expressions that start with There's a nice review of how to do this from class today posted here on our DHClass-Hub wiki. It's under the heading "Comparison Operators". |
@kes213 Of the XPath expressions you posted here, the last one looks the closest, but it's a little bit off: You're missing the function that would give a count of the |
Do I need to put the > in parenthesis? |
@kes213 No--you'd be taking a count() of just the geo elements you're seeking, so the parentheses for the function would just wrap the part that's doing the counting. The comparison operator could be Does that help? |
Well . . .
I tried this, and I still got an error. I just don't understand how to write the gt into the expression so that it works. I looked at the Intro to Xpath functions document on the Wiki and I still don't get it. |
I'll play around with it some more. |
Trust me I'm having so much trouble too. Everything on this assignment I was fine with--except this. |
@kes213 Ahh! You're very close! You're just having trouble positioning the parentheses. Look at the example I posted on the wiki from earlier today--and notice how the count() function wraps just the thing it's trying to count... |
This is the closest I've gotten, and it's still giving me 12 results. |
@kes213 @flowerbee1234 Here's that example I used in the wiki: Look at it closely:
|
That's the example I looked at to get my most recent expression, but it still didn't give me the single result I need. |
@kes213 Yes--now you've got the count() set properly in your predicate, but the position of last() is the thing to figure out. |
I put my last at the beginning. Still doesn't work |
@kes213 @flowerbee1234 Remember how you could find the very first instance of any XPath expression by walking the whole tree first and then positioning the [1] after it? Like this: (//p[geo])[1] Okay--that's a simpler XPath, but it's similar to what you do here. [1] is a position predicate, that says get the first in series. The |
I think I figured it out. I'll put whatever I have on my text file. |
I'm having a lot of trouble with #3, which reads:
I've tried building up from the simplest expression, but even the simple expressions are giving me errors. Here are what I've tried:
//p[geo[@select-"lat"]][2,]
//geo[@select="lat"][2,]/parent::*last()
(//p/geo[@select="lat"][2,])[last()]
(//p/geo[@select="lat" > 2])last()
I've probably tried at least 10 other ways to write this but I can't remember them all now. I don't know what I'm doing wrong. I just keep getting error after error. I'm trying to model my expressions after the greater than or equal to examples but it's not getting me anywhere. It keeps saying the gt needs parenthesis, but the examples on the Newtfire Xpath functions tutorial don't have parenthesis.
Can anyone help?
The text was updated successfully, but these errors were encountered: