The W3C announced the release of an API for the HTML validator or rather, that’s what they call it. In fact, it’s nothing more than an output filter on their normal validator output, which gives SOAP 1.2 conforming output. It requires a HTTP request though, which makes it a rather funny “API” to deal with.
I created a simple implementation on top of it, using PHP’s DOMDocument extension to walk through the result, as using NUSoap or something like that felt like overkill, and it would be hard since the request isn’t a SOAP request. It’s quite simple, but it’s also slow…
So, my wishlist for the next version of this API:
a way to do a SOAP request instead of a HTTP request;
faster, please, please W3C, make it faster;
a way to specify what info i want, it would be cool to be able to just know if a site is valid or not.
Joost is an internet entrepreneur and the founder of Yoast. He has a long history in WordPress and digital marketing. On our blog, he has written a lot about SEO in general, technical SEO and important topics related to SEO.
November 08, 2025
Team Yoast is Speaking at WordCamp Athens 2025! Click through to see who will be there, what we will do, and more!
See where you can find us next »
13 November 2025
Learn how to improve your website performance with effective strategies for WordPress speed that keep clients satisfied and engaged.
All Yoast SEO Webinars
Discussion (21)
ReneMay. 10, 2008
Excellent code, does anyone know how I can get this to work on php4. I know the DOMDocument needs to be changed, but I’m not sure what to.
Thanks.
yoshiApr. 21, 2008
i tried it but im having some errors
on this line [code]apc_fetch($url)[/code]
Joost de ValkDec. 16, 2006
NP, this is exactly what I intended by implementing it :)
SudarDec. 16, 2006
Thank for updating it.
Let’s hope that people at W3C come up with an elegant approach for API as well. :-)
Cheers,
Sudar
Joost de ValkDec. 16, 2006
Sudar: the webinterface errors as well, yet more elegant than the API does, I’ve email Olivier about it.
Joost de ValkDec. 16, 2006
Ey Sudar,
you’re right, I’ve thrown a more decent error now, but it does throw an error on the W3 side, so I’ll be mailing Olivier about that :)
Regards,
Joost
SudarDec. 16, 2006
Hi Joost,
The above code fails when we pass a url which is having invalid or wrong Charset.
You can use this page to check this http://googlemyway.com/searchgoogle.php
Cheers,
Sudar
ThinkbasicNov. 17, 2006
thnx guys!
Joost de ValkNov. 17, 2006
Olivier: thx for letting us know! Thinkbasic: i’ve enabled my implementation again :)
olivierNov. 17, 2006
Joost, Thinkbasic,
The API on validator.w3.org is enabled again. My apologies for the hiccup, and many thanks to Joost for telling me about it.
Joost de ValkNov. 17, 2006
I’ll let you know, probably through this blog :)
ThinkbasicNov. 17, 2006
Ok let me know when it works!
I want to use this on my website!
Joost de ValkNov. 16, 2006
Thinkbasic: you’re right, it’s disabled at the moment… I’ve emailed the responsible person at the W3C about it.
ThinkbasicNov. 16, 2006
hmmm I keep getting this message:
Didn’t receive an answer from W3 validator, please reload.
Joost de ValkNov. 06, 2006
fixed another small bug where it would say your document was invalid when it hadn’t received a proper response, it’s now all done it seems :)
Joost de ValkNov. 06, 2006
Thx for the tip on Curl, had to install it but it seems more stable indeed.
Joost de ValkNov. 06, 2006
The functions.php just does my layout, wouldn’t be much use to you :)
Joost de ValkNov. 05, 2006
I updated the validator API script to now show warnings and warningcount as well, it now uses all the data you can get from the API.
Joost de ValkNov. 04, 2006
Scott: you’re a guy to my heart :) I hope one day all webmasters will grasp this…
Scott at RealepicureanNov. 04, 2006
Some people still aren’t really fully into this validation thing, but for me, it’s as much about education as anything else.
I think browsers are intelligent enough to work around a few little hiccups, but still, we should all try and aim for the future.
Joost de ValkNov. 03, 2006
Perhaps I should read up on my SOAP, but tbh i think you’re wrong :). Downloading the validator is NOT what I’d want, since I couldn’t be bothered to completely install the thing… I think i’m giving all information that is coming back back…
Excellent code, does anyone know how I can get this to work on php4. I know the DOMDocument needs to be changed, but I’m not sure what to.
Thanks.
i tried it but im having some errors
on this line [code]apc_fetch($url)[/code]
NP, this is exactly what I intended by implementing it :)
Thank for updating it.
Let’s hope that people at W3C come up with an elegant approach for API as well. :-)
Cheers,
Sudar
Sudar: the webinterface errors as well, yet more elegant than the API does, I’ve email Olivier about it.
Ey Sudar,
you’re right, I’ve thrown a more decent error now, but it does throw an error on the W3 side, so I’ll be mailing Olivier about that :)
Regards,
Joost
Hi Joost,
The above code fails when we pass a url which is having invalid or wrong Charset.
You can use this page to check this http://googlemyway.com/searchgoogle.php
Cheers,
Sudar
thnx guys!
Olivier: thx for letting us know! Thinkbasic: i’ve enabled my implementation again :)
Joost, Thinkbasic,
The API on validator.w3.org is enabled again. My apologies for the hiccup, and many thanks to Joost for telling me about it.
I’ll let you know, probably through this blog :)
Ok let me know when it works!
I want to use this on my website!
Thinkbasic: you’re right, it’s disabled at the moment… I’ve emailed the responsible person at the W3C about it.
hmmm I keep getting this message:
Didn’t receive an answer from W3 validator, please reload.
fixed another small bug where it would say your document was invalid when it hadn’t received a proper response, it’s now all done it seems :)
Thx for the tip on Curl, had to install it but it seems more stable indeed.
The functions.php just does my layout, wouldn’t be much use to you :)
I updated the validator API script to now show warnings and warningcount as well, it now uses all the data you can get from the API.
Scott: you’re a guy to my heart :) I hope one day all webmasters will grasp this…
Some people still aren’t really fully into this validation thing, but for me, it’s as much about education as anything else.
I think browsers are intelligent enough to work around a few little hiccups, but still, we should all try and aim for the future.
Perhaps I should read up on my SOAP, but tbh i think you’re wrong :). Downloading the validator is NOT what I’d want, since I couldn’t be bothered to completely install the thing… I think i’m giving all information that is coming back back…