Questions tagged [domxpath]

domxpath is a class in PHP's DOM API to support XPATH 1.0

domxpath called the DOMXPath is a class in PHP's DOM API that support XPATH 1.0. It provides functions to run XPATH queries on the document and retrieve specific parts of the document

492 questions
3
votes
1 answer
3
votes
1 answer

try to grab data between class tag with PHP DOMXPATH

I am trying to grab the data between two css class tag in my html doc. Here the example.

text text

text text text

text text text

text text

I don't know how to grab the …
slphp
  • 43
  • 5
3
votes
2 answers

creating preg_match using xpath in php

I am trying to get the contents using XPATH in php.
Hi
I am using below php code to get the output. $dom =…
karthick
  • 1,273
  • 1
  • 10
  • 19
3
votes
1 answer

Getting second p tag inside a specific ID from HTML ysubg DOMDocument

How can I get content from the second

tag inside a div with ID mydiv using DOMDocument? For example, my HTML might look like:

i need here

lorem ipsum lorem ipsum

I'm trying to…
ersanyus
  • 103
  • 2
  • 9
3
votes
0 answers

How to traverse child elements by xpath in DomNodeList?

I have this PHP script: loadHTMLFile("http://domain.com/catalog/0_1.html"); /* Create a new…
3
votes
3 answers

Parse anchor tags which have img tag as child element

I need to find all anchor tags, which have an img tag as child element. Consider the following cases, Test 1 Test 2
Nikhil Mohan
  • 891
  • 6
  • 13
3
votes
4 answers

Parse HTML with PHP DOM - Class contains text

I have a set of html items which are to be parsed. I need to parse the contents of a div whose class name ends with 'uid-g-uid'. Below are the sample divs...
1121
14234
Guns
  • 2,678
  • 2
  • 23
  • 51
3
votes
3 answers

Unable to extract data from Soap response

This is the code im using: $doc = // SOAP Response $xpath = new DOMXPath($doc); $xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xpath->registerNamespace('api',…
D_R
  • 4,894
  • 4
  • 45
  • 62
3
votes
2 answers

Get DOMXpath results below previous result in HTML

I'm trying to sort through the HTML of an external website and, unfortunately, the site is very poorly organized. The data might look something like this: Title One Item One Item Two
GhostCode
  • 578
  • 1
  • 8
  • 18
3
votes
1 answer

Using DOMDocument and DOMXPath how can I ignore some characters for the match?

I'm using the DOMDocument and DOMXPath to determine the presence of some phrase (Keyword phrase) in my HTML content, for example to search if the Keyword is in Bold. I use the follow code and works fine except that I need to "ignore" some characters…
leticia
  • 2,390
  • 5
  • 30
  • 41
3
votes
1 answer

DOMXpath remove tag

I have this HTML code:
Hello World
I do this:$res = $xpath->query(//div[@class='lvlone']/div[@class='lvltwo']); I get Hello World including the string in
Manos Serifios
  • 577
  • 2
  • 7
  • 22
3
votes
3 answers

PHP - DOMXpath - Get the result

I have errors when I want to print the result of an evaluate expression with XPath. $url = $xpath->evaluate('//a/@href', $event); echo $url ; I have this error : Catchable fatal error: Object of class DOMNodeList could not be converted to string My…
geekInside
  • 588
  • 2
  • 8
  • 18
2
votes
1 answer

How to remove style attribute only with DOMXPATH?

I use DOMXPATH to remove all attributes from the p tag and it works fine, // Loop all p. foreach( $dom->getElementsByTagName( "p" ) as $p ) { // Loop all attributes in p. foreach( $p->attributes as $attrib ) { // Remove all…
Run
  • 54,938
  • 169
  • 450
  • 748
2
votes
3 answers

Get the width and height of each element's attribute via DOM or XPATH

How can I get the width and height of each element's attribute? For instance, $dom = new DOMDocument; $dom->loadHTML('
'); foreach(…
Run
  • 54,938
  • 169
  • 450
  • 748
2
votes
2 answers

How to skip the item in an rss feed if the `description`node does not exist?

How do I skip the item in an rss feed if the description text does not exist? I tried with this line below but I still get an error, if($x -> item($i) -> getElementsByTagName('description')) { then proceed } when I the item in the rss feed appears…
Run
  • 54,938
  • 169
  • 450
  • 748
1 2
3
32 33