domdocument
How to delete element with DOMDocument?
You remove the node by telling the parent node to remove the child: $href->parentNode->removeChild($href); See DOMNode::$parentNodeDocs and DOMNode::removeChild()Docs. See as well: How to remove attributes using PHP DOMDocument? How to remove an HTML element using the DOMDocument class
What is anchorNode , baseNode , extentNode and focusNode in the object returned by document.getSelection?
According to MDN selection.anchorNode – returns the Node in which the selection begins. selection.focusNode – returns the Node in which the selection ends. because there were debates on naming: baseNode is alias for anchorNode extentNode for focusNode Note: references to both baseNode and extentNode have been removed from the MDN page. The following is beyond … Read more
document.getelementbyId will return null if element is not defined?
console.log(document.getElementById(‘xx’) ) evaluates to null. document.getElementById(‘xx’) !=null evaluates to false You should use document.getElementById(‘xx’) !== null as it is a stronger equality check.
PHP DOMDocument failing to handle utf-8 characters (☆)
DOMDocument::loadHTML() expects a HTML string. HTML uses the ISO-8859-1 encoding (ISO Latin Alphabet No. 1) as default per it’s specs. That is since longer, see 6.1. The HTML Document Character Set. In reality that is more the default support for Windows-1252 in common webbrowsers. I go back that far because PHP’s DOMDocument is based on … Read more
XPath Query: get attribute href from a tag
For the following HTML document: <html> <body> <a href=”http://www.example.com”>Example</a> <a href=”http://www.stackoverflow.com”>SO</a> </body> </html> The xpath query /html/body//a/@href (or simply //a/@href) will return: http://www.example.com http://www.stackoverflow.com To select a specific instance use /html/body//a[N]/@href, $ /html/body//a[2]/@href http://www.stackoverflow.com To test for strings contained in the attribute and return the attribute itself place the check on the tag not on … Read more