37

XPath: Select parent node when the value of the child property begins with the v...

 2 years ago
source link: https://www.codesd.com/item/xpath-select-parent-node-when-the-value-of-the-child-property-begins-with-the-value.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

XPath: Select parent node when the value of the child property begins with the value

advertisements

I need to select all parent nodes of type FOO where BAR nodes are childs and the BAR node has a attribute A that starts with X.

e.g. In the example below, i would like to select FOO (id = A) because i have a BAR with attribute A starting with an X.

<rumba>
  <latin>
    <FOO id="A">
      <BAR id="1" A="XYZ" />
      <BAR id="2" A="ABC" />
    </FOO>
  </latin>
  <salsa>
    <FOO id="B">
      <BAR id="3" A="UVW" />
    </FOO>
  </salsa>
</rumba>

I am pretty sure this can be done in XPATH, but I can't get my head wrapped around this one.


//FOO[BAR[starts-with(@A, 'X')]]

Related Articles

How to get the parent node of a value in an xml file using vb.net?

Below is my XML file and function to get the parent node using a value. But i am struck to get the parent node. When the value 133 is passed to function it should return "firstnode" and when 124 is passed to function it should return "secon

Pre-parent the parent node when serializing the C # property

I'd like to serialize the following class to xml: public class Survey { [XmlElement("edit")] public string EditLink { get; set; } } As expected this serializes as (removed extra stuff not important to the question) <Survey><edit>http

Javascript + How to get the index w.r.t the parent node of the selection + non IE browsers

Hi I want to get the selection start and end index with respect to the parent node of the selected text. I am able to do this in IE. However in other browsers like Firefox, Opera, Safari and Chrome, I am able to access the selection and the index of

How can I get a folder icon on all parent nodes and the plus folder icon on all child nodes (shoulbe icon on the left side)

I want to get icons before the nodes of the Parent node and the child nodes. For parent nodes it should be icomoon-icon-folder-plus and for child nodes it should be 'icomoon-icon-folder'. function treeView() { var treeMenu = new kendo.data.Hierarchic

xpath - select a node value if another node value exists

I have several nodes (see below). I know how to select specific nodes which have a certain attribute. But in this case I would like to import the "file_url" value of the media objects that belong to the group "narrowImage". <media_o

Retrieve the parent node from the selection (range) in Gecko and Webkit

I am trying to add an attribute when using a wysiwyg editor that uses "createLink" command. I thought it would be trivial to get back the node that is created after the browse executes that command. Turns out, I am only able to grab this newly c

Retrieves the parent element node when the child node is associated

This is my code: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> var xml; $.get( "code.xml", function(data) { xml=data; }, "html" );

Send the value of the selected TreeView node to the text box without publication

I've been working on this for quite a while and haven't found anything to solve my problem. When I select a node I want the value of that node to populate a textbox. I can get this to work using vb codebehind but it causes a postback and I don't want

How to select the XML root node when the root node has an attribute?

I am trying to select all the child nodes of root node of an xml document using XPath query. My xml file looks something like following : <?xml version="1.0" encoding="UTF-8" ?> <root> <automotive_industry> <automo

How to create a node when the user submits values ​​in the Web form and click Submit?

My website(D6) have "Quick Enquiry Form"(using webform) & i need to create a new node simultaneously when user click the submit button in webform. How do i get values from the webform and insert the values to the node when user click the sub

How to return to the parent node in the XML file using the Xpath query (using XSLT)?

Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node. Please let me know the syntax for the XPATH query so that i can reac

Xpath - How to select parent based on the child's attribute?

How do you select a parent based on the attribute of a child? I want to select a div: //*[@id='outer']/div/div/div/div that has a child with the 'a href' attribute equal to 'www.blah.com': //*[@id='outer']/div/div/div/div/a[@href='www.blah.com'] The

Kendo Treeview checked Get a parent node when checking child nodes

enter image description hereI´m trying to use a treeview with checkboxes for definition User Rights. (2 actions - enabled/disabled right) How can I to get value (id) from parent node ? Kendo tree viewThis example will return the parent id for the sel

d3.js: Passing data from the parent node to the onclick event of the child node

I am using d3 to make a stacked bar chart. Thanks to this previous question I am binding data associated with a parent node to a child node using parentNode.__ data__.key. The data is an array with one object for each bar (e.g 'likes'). Then each obj

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK