I use DOMDocument for editing some HTML files, but some of theme have in their names spaces. So DOMDocument automaticly change the spaces to %20 and then can’t find them. This is how looks the error exactly: How to repair this error? Answer Use DOMDocument::loadHTMLFile() instead of load(). That’s what it has been made for. HTML is not XML. XML
Tag: domdocument
PHP XML how to output nice format
Here are the codes: If I print it in the browser I don’t get nice XML structure like I just get And I want to be utf-8 How is this all possible to do? Answer You can try to do this: You can make set these parameter right after you’ve created the DOMDocument as well: That’s probably more concise. Output
Can’t print_r domDocument
I only see: DOMNodeList Object ( ) is this a php bug or something? How am I supposed to see the HTML elements from the object? Answer When you create a DOMDocument instance, you have a PHP object. The DOM classes do not implement a helpful __toString functionality. To get HTML from a DOMDocument instance, you’ll need to use saveHTML:
Is there a way to get all of a DOMElement’s attributes?
I’m reading some XML with PHP and currently using the DOMDocument class to do so. I need a way to grab the names and values of a tag’s (instance of DOMElement) attributes, without knowing beforehand what any of them are. The documentation doesn’t seem to offer anything like this. I know that I can get an attribute’s value if I