문제

I'm getting from user a URL to webpage OR sitemap.

What is simplest way to check the type (Sitemap or Webpage) of the given URL?

Thank you!

도움이 되었습니까?

해결책

Having sought clarification of the question, here is what you'll need to do:

  1. Check the URL is valid and fetch the contents.
  2. Validate the contents against the XML-based sitemap spec at http://www.sitemaps.org/protocol.html. This can best be done by defining classes that map to urlset and url and by de-serializing the XML to those types.
  3. If it's valid XML, then treat it as a sitemap.
  4. If it's invalid XML, you may wish to warn the user, or just treat it as a webpage.
  5. If not XML, you may treat it as a webpage.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top