<link rel='canonical' href='http://test.com/asdfsdf/sdf/' />
I need to get the canonical href value using Dom. How do I do this?
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.
There are multiple ways to do this.
Using XML:
which outputs:
or, using Dom:
which outputs:
In both examples, more code is required if you’re parsing an entire HTML file, but they demonstrate most of the structure that you’ll need.
Code modified from this answer and the documentation on Dom.