How can I read tag attributes and classes with DOMDocument, DOMNode and the rest of the family?
And, intended to be working with HTML not XML.
Maybe any useful extensions/modules to be used for this?
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually this is all in the PHP Manual, so I give some hints:
These objects have methods available to access attributes, like
getAttribute.Use
DomDocument->loadHTML()to load HTML, this makes it very similar to XML handling.It’s all in the Dom Extension, normally you can do pretty everything with it and no additions are necessary. XPath is part of the Dom Extension as well. However there are libraries like QueryPath or FluentDom that might encapsulate a bit more what you’re looking for, e.g. for classes.