Showing posts with label XML::LibXML. Show all posts
Showing posts with label XML::LibXML. Show all posts

Tuesday, January 24, 2012

perl: XML::LibXML::XPathContext - registerNs

XML::LibXML::XPathContext - XPath Evaluation - metacpan.org

If your XML has a namespace without prefix (xmlns="…" instead of xmlns:aaa="…", where 'aaa' would be called the prefix), you still have to provide registerNs with a proper prefix and use that prefix from then on; no undef or zero-length string allowed as prefix.
Learning this lesson cost me some sleep last night.

syndication feeds for blogs on Blogger.com take CGI parameters

You can find the URL-s of the Atom and the RSS feeds for such a blog in its HTML:

/html/head/link[@rel="alternate" and @type="application/atom+xml"]/html/head/link[@rel="alternate" and @type="application/rss+xml"]


Within the XML of an Atom feed you can find a node like this:

/feed/link[@rel="next"] 
 /feed/link[@rel="next" and type="application/atom+xml"] 
Found 1 nodes:
-- NODE --


The href attribute looks rather interesting, it uses these CGI parameters:
  • start-index
  • max-results




Actually the href used the somehow internal URL of that blog, but apparently both "public" URL and internal URL seem rather interchangeable – trial and failure "proved" that. Furthermore these CGI parameters also work on the URL of the RSS feed, not just the Atom feed.

BTW: Both feed XML-s carry an element openSearch:totalResults, find it like this:
/feed/openSearch:totalResult
/rss/channel/openSearch:totalResult
… for Atom resp. RSS.


It tells you exactly, what it says, i.e. the number of total results.


So you may very well read blog feed XML-s in small chunks, until you reach their end. I assume, this is what Google Reader does e.g. . It shows you the most recent blog articles (resp. their stubs) initially, and extends the list, when it notices, you are scrolling "beyond the end".

Yes, reading XML can be fun. Of course tidying helps (me) a lot, and emacs's nxml-mode in my case.

Of course, any pointers to relevant Blogger API documentation is kindly appreciated.