Questions tagged [xpathquery]

48 questions
175
votes
4 answers

How to use "not" in XPath?

I want to write something of the sort: //a[not contains(@id, 'xx')] (meaning all the links that there 'id' attribute doesn't contain the string 'xx') I can't find the right syntax.
Guy
  • 12,478
  • 25
  • 61
  • 86
25
votes
3 answers

PHP xpath contains class and does not contain class

The title sums it up. I'm trying to query an HTML file for all div tags that contain the class result and does not contain the class grid.
skip this div
grab this one
Thanks!
Rob
  • 575
  • 1
  • 6
  • 19
18
votes
1 answer

Getting elements with default namespace (no namespace prefix) using XPath

In this SOAP XML file, how can I get the 7 on a using a XPath query?
user2411903
  • 191
  • 1
  • 1
  • 3
8
votes
1 answer

How to negate xpath query?

I would like to do a negative xpath query like this: $xpath->query(//a[DoesNotContain(@class,'some_class')]); I know about this $xpath->query(//a[contains(@class,'some_class')]);
sam
  • 185
  • 2
  • 12
5
votes
1 answer

XPath Query to parse all IDREFS in an attribute (containing possibly many of IDs)

I need to come up with a query that gives the products of the types from which no items were sold Meaning if an item is of the type clothing, and no clothing items appear in the list of transactions, I need to display it. This is my XML file…
CodyBugstein
  • 17,496
  • 50
  • 159
  • 312
3
votes
1 answer

Xpath query with multiple nodes at different levels

I need a Xpath query to find a XML file with certain nodes. The nodes are located at different levels in the XML file, under different parents. So, it would be like if I want to recover a file like the one below using the nodes "author" and "ref…
Iria
  • 81
  • 4
3
votes
1 answer

In CrafterCMS, how can I query a model to get an array with all the fields in a repeated group?

In CrafterCMS, I have a component Team with a itemSelector field where I'm assigning some instances of another component TeamMember. In the template of Team I'm using siteItemService.getSiteItem to get the model information of child…
kmarcos
  • 179
  • 6
2
votes
1 answer

How do I write "if elsif" conditions using basic XPath?

I have a very basic XML and wanted to write an Xpath query to get a value. Here is XML:
STD 1234
kmatrix
  • 21
  • 1
2
votes
0 answers

How to declare array in xpath query using oracle

I am trying to create an array in XPath query using oracle, but it is treating as a string, below is the code snippet, can someone please help me where I am doing wrong. XMLQUERY(' let $vals := if (count($Cntnt/emp/emp_content/emp_part)=1)…
Saritha
  • 79
  • 7
2
votes
1 answer

PHP + XPath Query get Child Nodes and their values

I have a XML file record.xml which looks like: john male mathematics, english, science jamie female
Ajay
  • 448
  • 3
  • 18
2
votes
2 answers

Xpath Query to match immediate sibling nodes in a sequence

I'm new to XPATH and I'd like to know if there is a nice way to do this using XPATH queries. I want to match consecutive sibling nodes in a XML tree to certain predefined rules for example if there are three sibling nodes occurring immediately one…
2
votes
1 answer

DomXPath: Search inside DomXPath query result?

How can I query an xpath result for a sub element, without querying the entire document again? I query my document to find the last
  • with the class menu-item: $doc = new DomDocument(); @$doc->loadHTML( $html ); // $html is invalid (and should be…
  • Brian Graham
    • 12,107
    • 12
    • 55
    • 95
    2
    votes
    2 answers

    xpath query to search string in a webpage

    I am using html agility for below task. I am wondering what can be xpath query to get all the nodes containing a string search term. It should search both attributes and innertext of elements.

    Mr T for president

    sunder
    • 1,775
    • 3
    • 27
    • 47
    2
    votes
    2 answers

    Get title tag from html page using XPath?

    I have two pages that Im trying to extract the title tag from using an Xpath query. This page works: http://www.hobbyfarms.com/farm-directory/category-home-and-barn-resources-1.aspx This page…
    RachelD
    • 3,912
    • 8
    • 38
    • 67
    1
    vote
    1 answer

    DOMDocument xpath query cut off withing a specific timeframe ?

    is there a way to cut of the query and return back the results.. preset time to take to get all images from the given url .. i.e. query half of the webpage ? or job time not greater than 5 seconds, so therefore, it will get everything it can in 5…
    dean jase
    • 1,151
    • 5
    • 23
    • 37
    1
    2 3 4