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
4
votes
1 answer

Correctly deleting child elements in PHP using DOMDocument and DOMXPath

This was previous another question, but we won't talk about that. I am isolating a number of sections in a third party HTML document. When matching some, I need to remove certain tags from the result. The code I found for this on SO was: $name =…
user137621
4
votes
3 answers

Choose multiple class name and get childnode inside that class with PHP DOMXpath

"child node that i want to get"
"child node that i want to…
Webber Depor
  • 198
  • 4
  • 16
4
votes
1 answer

How to append the text (increasing order) using DOM parser in PHP?

$html='

Exponents[label*exponents]

Exponents[label*exponents]

Exponents[label*exponents]

Exponents[label*exponents]

Learning
  • 848
  • 1
  • 9
  • 32
4
votes
2 answers

domxpath - Extract li tags from second ul

I am trying to extract only the second ul's li tags from the following. Unfortunately, there are no classes or ids in the html to help
  • Some text
  • Some text
  • Some text
  • Some more text
jmadsen
  • 3,635
  • 2
  • 33
  • 49
4
votes
1 answer

php xml dom getElementById and DOMXpath query fails getting element

I have some problems making a function to replace question and answer elements in my XML file. I did alot of research learning php dom but I'm running stuck at making this function. The problem is that when I'm trying to get the parent element row…
Zeebats
  • 480
  • 7
  • 22
3
votes
4 answers

Php - Dom, Insert HTML_CODE inside nodeValue

$dom= new DOMDocument('1.0', 'iso-8859-1'); $dom->loadHTML(' SECOND '); $path = new DOMXPath($dom); foreach($path->query('body') as $found){ $found->nodeValue = ' FIRST
user534312
  • 91
  • 2
  • 7
3
votes
2 answers

DOMXPath get sibling depending on previous sibling value

Let's say I have this: CCC sometexthere AAA sometext DDD something Now, I want to get the baz value, which is coming…
kkkwww
  • 33
  • 4
3
votes
2 answers

DOMXPath $html->query('//p[@class="myclass"]/a')->item(0); not working

DOMXPath $html->query('//p[@class="myclass"]/a')->item(0); is not working. Here is the HTML:

Grego
  • 2,220
  • 9
  • 43
  • 64
3
votes
1 answer

PHP: "Couldn't fetch DOMElement. Node no longer exists in" using DOMXpath

I have some HTML that contains this:
Outer
Inner 1
Inner 2
I'm doing str_replace() on the contents of these elements: $dom = new…
Phil Gyford
  • 13,432
  • 14
  • 81
  • 143
3
votes
1 answer

How to query graphml using php, DomDocument and DomXPath?

Does someone know how to query a graphml document with php, DomDocument and DomXpath? My query seems to be correct. e.g. //graphml/graph/node $dom = new DomDocument(); $dom->load("doc.graphml"); $x = new DOMXPath($dom); $x->registerNamespace('y',…
3
votes
3 answers

DOMXPath query attribute that contains Unicode character

Is it possible to access element that contain Unicode class name? I'm actually accessing this site, but their class name are prefixed with Unicode character U+1F41D HONEYBEE $html =…
Js Lim
  • 3,625
  • 6
  • 42
  • 80
3
votes
2 answers

Add content of a table into an array using DOMDocument

I have $html: $html = ' …
Henrik Petterson
  • 6,862
  • 20
  • 71
  • 155
3
votes
2 answers

Get full XPath from partial

I am using selenium with perl and have label on page, to access this label i have following xpath: //*[text()='some here'] , the problem that a need to get full xpath of this element, like /html/body/table/tr/..../any other/and other/ , is there is…
CODERED
  • 31
  • 1
3
votes
1 answer

Debugging of object of DOMXPath and DOMDocument

We use echo or print_r to get value of variables while debugging PHP code. But, object of DOMXPath or DOMDocument are not captured in echo or print_r. How to get values from above objects while debugging PHP code?
Pradip
  • 1,317
  • 4
  • 21
  • 36
3
votes
1 answer
08/20/18 Text 1 A Test 1 B
isnvi23h4
  • 1,910
  • 1
  • 27
  • 45
1
2
3
32 33