0

I use this piece of Java with the XOM library to parse a sitemap.

Element root = doc.getRootElement();
Elements urls = root.getChildElements("url");

When I'm debugging, I can see that root has a whole bunch of children, both url elements and text elements. However, root.getChildElements("url") returns an empty list.

What am I doing wrong?

damd
  • 6,116
  • 7
  • 48
  • 77

1 Answers1

1

I just realized that the sitemap I'm parsing uses a default namespace, which is "http://www.sitemaps.org/schemas/sitemap/0.9".

Changing the code to root.getChildElements("url", "http://www.sitemaps.org/schemas/sitemap/0.9") gives me the right result.

damd
  • 6,116
  • 7
  • 48
  • 77