Questions tagged [domdocument]

DOMDocument refers to a class encapsulating the DOM (Document Object Model). Various languages and technologies use the name DOMDocument for this purpose, for example PHP, COM, C++, and ActiveX

If you are thinking of using this tag, then you might be looking for the Document Object Model tag:

In PHP, for example, the DOMDocument class represents an entire HTML or XML document and serves as the root of the document tree.

2749 questions
0
votes
1 answer

DOMdocument, editing elements

So, what I want to do, is make a script that will automatically add my login info(which i will have in my database) to whatever form I want. To do this, I get the html source from the website(using cURL) then with DOMdocument i'm editing the input's…
alex2005
  • 31
  • 6
0
votes
1 answer

Getting 'DomNode' type object in php

I am using php's DomDocument class to load an HTML file and then empty its contents. The problem is when I do .removeChild() it gives me 'Not Found Error'. heres my code $doc=new DOMDocument(); $doc->loadHTMLFile("a.html"); $body=…
samach
  • 3,244
  • 10
  • 42
  • 54
0
votes
0 answers

PHP: I have a string of HTML from another site, and I want to fix all local URLs. What's the best/easiest way to do this?

A little bit of background (you can skip this): I'm trying to create a simple proxy using PHP. All I am doing right now is using file() on a URL string and echoing everything with a foreach loop (if you really want to see it, it's here). Anyway, I…
Hayden Schiff
  • 3,280
  • 19
  • 41
0
votes
0 answers

How to submit POST data with DOMDocument

I want to submit POST data using the DOMDocument class (DOMDocument::loadHTMLFile() to be precise) to simulate a html form using the post method being submitted. For that purpose I tried to set my params using stream_context_set_default() but…
Anticom
  • 975
  • 13
  • 29
0
votes
1 answer

Change code cause Uncaught Error: Call to a member function getElementsByTagName()

i have a problem cause probably design of site have been changed and my scrips doesn't work. The problem is Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on null in C:\xampik\htdocs\łamaki\open-triangle.php:177 Stack…
Guzinek
  • 1
  • 1
0
votes
1 answer

Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty

I want to scrape this website in PHP using cURL. I use similar webscraping scripts in PHP, they work well. Nevertheless, I get the following error: Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty,…
anpami
  • 760
  • 5
  • 17
0
votes
1 answer

Magento 2 - Uncaught Error: Class "DOMDocument"

I am using magento commerce cloud, and when I try to execute selected command below: vendor/bin/mftf generate:tests Then this error is shown in console: Uncaught Error: Class "DOMDocument" not found in…
Denis2310
  • 939
  • 1
  • 15
  • 41
0
votes
0 answers

Problem with encoding when use insertBefore in DOMDcocument with WordPress response

I have a php variable with html, I want to make some changes with DomDocument, like insert a new tag with: $dom->getElementsByTagName('div')->item(0)->insertBefore($new_element, $first_child); everything work fine but when are present special…
gassiopea
  • 7
  • 2
0
votes
1 answer

Trying to find XML tags but getElementsByTagName returning 0 length

I am trying to edit some XML via VBA and find tags using the getElementsByTagName method but it is not returning anything. The XML File is as follows
Munki Fisht
  • 37
  • 1
  • 6
0
votes
0 answers

Getting the DOMDocument Results after JS execution

I am working with PHP cURL/DOMDocument to scrape webpages. It works well, but I have some pages that loads the actual content after certain JS execution, In this scenario, the Xpath query returns null as it scraps the content from the target webpage…
0
votes
1 answer

Css grid width dynamic content including linebreaks

On our website we have got a simple BB-Code based editor to create our posts. To be able to create basic grids I added a new tag which is a simple wrapper with display:grid and grid-template-columns: repeat(2, 1fr). So the input looks something like…
0
votes
0 answers

DOMDocument::loadXML(): Opening and ending tag mismatch: br line 1 and p in Entity, line

This code fetches a service request from the database, retrieves the request data and service information. It uses an HTML template and replaces placeholders with actual data. Then, it generates a Word document using PHPWord library and downloads it…
0
votes
0 answers

DomDocument not showing special chars (UTF printing)

I have a file writed in french language and I want to load it with DomDocument to parse it $this->doc = new \DomDocument('1.0', 'UTF-8'); $url = $this->file_get_contents_utf8('/file.html'); $array = Array(); $internalErrors =…
0
votes
2 answers

Replacing text in DOMDocument only works on the first few tags

I'm using PHP DOMDocument in order to loop through an html string like this: $htmlString = "

text

text

text

text

text

gabogabans
  • 3,035
  • 5
  • 33
  • 81
0
votes
0 answers

DomDocument next and previous siblings from formatted HTML doesn't work

Using this code as an example to test: $dom = new DOMDocument(); $dom->preserveWhiteSpace = TRUE; @ $dom->loadHTML($html); $mydocnodes = $dom->getElementsByTagName('*'); foreach($mydocnodes as $node) { $title_text = $node->textContent; …