Questions tagged [xpath]
The primary purpose of XPath is to address parts of an XML document. It also provides basic facilities for manipulation of strings, numbers and booleans. XPath uses a compact, non-XML syntax. XPath operates on the abstract, logical structure of an XML document, rather than its surface syntax.
xpath
39,495
questions
7
votes
2
answers
16k
views
Using SQL Server 2005's XQuery select all nodes with a specific attribute value, or with that attribute missing
Update: giving a much more thorough example.
The first two solutions offered were right along the lines of what I was trying to say not to do. I can't know location, it needs to be able to look at ...
6
votes
5
answers
7k
views
Flatten XML to HTML table
There must be a generic way to transform some hierachical XML such as:
<element1 A="AValue" B="BValue">
<element2 C="DValue" D="CValue">
<element3 E="EValue1" F="FValue1"/>
...
15
votes
7
answers
38k
views
Get list of XML attribute values in Python
I need to get a list of attribute values from child elements in Python.
It's easiest to explain with an example.
Given some XML like this:
<elements>
<parent name="CategoryA">
...
-1
votes
4
answers
2k
views
How do get element out of xml file
I get an XML file From a web service. Now I want to get one of those elements out of the file.
I think I should go use XPath - any good starter reference?
4
votes
2
answers
706
views
Getting The XML Data Inside Custom XPath function
Is there a way to get the current xml data when we make our own custom XPath function (see here).
I know you have access to an XPathContext but is this enough?
Example:
Our XML:
<foo>
<...
8
votes
5
answers
25k
views
Match conditionally upon current node value
Given the following XML:
<current>
<login_name>jd</login_name>
</current>
<people>
<person>
<first>John</first>
<last>Doe</last>...
3
votes
2
answers
5k
views
How to load an xml string in the code behind to databound UI controls that bind to the XPath of the XML?
Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding.
Idea is to edit a dynamic XML (structure known to the ...
5
votes
1
answer
9k
views
Count the number of nodes that match a given XPath expression in XmlSpy
I am using XmlSpy to analyze an xml file, and I want to get a quick count of the number of nodes that match a given xpath. I know how to enter the XPathand get the list of nodes, but I am really just ...
40
votes
3
answers
27k
views
Can XPath match on parts of an element's name?
I want to do this:
//*fu
which returns all nodes whose name ends in fu, such as <tarfu /> and <snafu />, but not <fubar />
10
votes
5
answers
7k
views
Can I create a value for a missing tag in XPath?
I have an application which extracts data from an XML file using XPath. If a node in that XML source file is missing I want to return the value "N/A" (much like the Oracle NVL function). The trick is ...
16
votes
3
answers
12k
views
How do I select an XML-node based on its content?
How can I use XPath to select an XML-node based on its content?
If I e.g. have the following xml and I want to select the <author>-node that contains Ritchie to get the author's full name:
&...
12
votes
4
answers
10k
views
XPath and Selecting a single node
I'm using XPath in .NET to parse an XML document, along the lines of:
XmlNodeList lotsOStuff = doc.SelectNodes("//stuff");
foreach (XmlNode stuff in lotsOStuff) {
XmlNode stuffChild = stuff....
17
votes
5
answers
11k
views
XPATHS and Default Namespaces
What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces? If I have a document where elements have been given a default namespace:
<foo xmlns="...
3
votes
5
answers
455
views
Regex Rejecting matches because of Instr
What's the easiest way to do an "instring" type function with a regex? For example, how could I reject a whole string because of the presence of a single character such as :? For example:
this - ...
263
votes
11
answers
387k
views
How to use XPath in Python?
What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its website?