Really Simple XPath Query. (Not to me)
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello there !
Well, It's always a sincere pleasure to post in this forum asking for help. so far what I learned from this forum alone, has been awesome. and I'm grateful for that.
Ok, let's cut to the chase. Could I trouble you guys with another Question? (that may seem so easy to you, yet complicated to me).
Here it goes:
What's the XPath query to look up for all nodes in an XML that start with a token word?
Since my question may not be enough information for you to understand me, let me detail the real scenario here.
Given the following XML:
What is the XPath Query to look up for all the nodes that start with the word: complex
As a result of such Query I should get a total of 4 nodes.
complex1
complex2
complex3
complexTooMuch
So, could you please help me out? I have made some attempts at it myself, but so far have not been successful.
Best Regards,
Your Friend,
Jose.
Well, It's always a sincere pleasure to post in this forum asking for help. so far what I learned from this forum alone, has been awesome. and I'm grateful for that.
Ok, let's cut to the chase. Could I trouble you guys with another Question? (that may seem so easy to you, yet complicated to me).
Here it goes:
What's the XPath query to look up for all nodes in an XML that start with a token word?
Since my question may not be enough information for you to understand me, let me detail the real scenario here.
Given the following XML:
What is the XPath Query to look up for all the nodes that start with the word: complex
As a result of such Query I should get a total of 4 nodes.
complex1
complex2
complex3
complexTooMuch
So, could you please help me out? I have made some attempts at it myself, but so far have not been successful.
Best Regards,
Your Friend,
Jose.
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The problem is, none of those nodes start with that string. What you mean is, you want to find all the nodes whose element names start with that string.
There are XPath functions to get the name of an element. There are string functions in XPath like substring. Were those part of what you tried so far?
There are XPath functions to get the name of an element. There are string functions in XPath like substring. Were those part of what you tried so far?
Jose Campana
Ranch Hand
Posts: 339
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello Again Paul,
Thank you very much man. I must admit that my Knowledge on Xpath is anything but extensive. What I have tried so far are basically things I've seen in other web sites, Mostly I tried to apply predicates, But I'm certain that I'm totally misusing those because I'm even getting Exceptions when I try them.
Now. You've revealed that the terms I'm using to refer to XML related 'things' are wrong, And I apologize, like I said before, I'm only a novice to this technology. So to put it in different terms... Yeah, I'm trying to structure a Query that does what you described. ie. look up by Node Name ? (Even there I may be wrong in terms of conventions).
I'd like to take this opportunity and, describe a little more what I'm trying to do...
If wanted to get the node complex2 from anywhere in the XML, I would use the Following XPath Query:
//complex2
Really Simple, right ?
So, I figured there could be a function or token or something inside the XPath Language that allows me to lookup all the nodes that start with the word:
complex (in my case);
In a way that'd be similar to this: (As an XPath Query)
//complex*
Where the * is the missing piece of code that I'm Missing. And Need
So, I hope somebody Can help me out. I'm still Clueless. However I'll research On substrings as Paul Suggested.
Thank you very Much !
Sincerely,
Jose.
Thank you very much man. I must admit that my Knowledge on Xpath is anything but extensive. What I have tried so far are basically things I've seen in other web sites, Mostly I tried to apply predicates, But I'm certain that I'm totally misusing those because I'm even getting Exceptions when I try them.
Now. You've revealed that the terms I'm using to refer to XML related 'things' are wrong, And I apologize, like I said before, I'm only a novice to this technology. So to put it in different terms... Yeah, I'm trying to structure a Query that does what you described. ie. look up by Node Name ? (Even there I may be wrong in terms of conventions).
I'd like to take this opportunity and, describe a little more what I'm trying to do...
If wanted to get the node complex2 from anywhere in the XML, I would use the Following XPath Query:
//complex2
Really Simple, right ?
So, I figured there could be a function or token or something inside the XPath Language that allows me to lookup all the nodes that start with the word:
complex (in my case);
In a way that'd be similar to this: (As an XPath Query)
//complex*
Where the * is the missing piece of code that I'm Missing. And Need
So, I hope somebody Can help me out. I'm still Clueless. However I'll research On substrings as Paul Suggested.
Thank you very Much !
Sincerely,
Jose.
Jose Campana
Ranch Hand
Posts: 339
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello !
I Solved it ! I Solved it !
Thanks anyway.
Have a Nice day.
I Solved it ! I Solved it !
Thanks anyway.
Have a Nice day.
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You solved it? Excellent!
And yes, a lot of the problems I see people having with XML is that they don't know the names of XML concepts. Or worse, that they know some names from HTML (like "tag") and they misapply those to XML.
And yes, a lot of the problems I see people having with XML is that they don't know the names of XML concepts. Or worse, that they know some names from HTML (like "tag") and they misapply those to XML.
Jose Campana
Ranch Hand
Posts: 339
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Paul,
Thanks for the advice. I solved it, and you were right I had to use a function to accomplish my goal. I have a doubt, You see I thought this was a node:
<myNode>text goes here</myNode>
and therefore I assumed that the String there, "text goes here" was the value or Text Content for the node..... Is it not?
If it's not could you please tell me why it's not? Where does my misconception lie?
Thanks again,
Jose
Thanks for the advice. I solved it, and you were right I had to use a function to accomplish my goal. I have a doubt, You see I thought this was a node:
<myNode>text goes here</myNode>
and therefore I assumed that the String there, "text goes here" was the value or Text Content for the node..... Is it not?
If it's not could you please tell me why it's not? Where does my misconception lie?
Thanks again,
Jose
| I'm still in control here. LOOK at this tiny ad! Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











