
Question:
Can anyone explaing me this line in detail?
// Find all the RSS link elements. var result = doc.evaluate( '//*[local-name()="rss" or local-name()="feed" or local-name()="RDF"]', doc, null, 0, null);
Best Regards, Cetin
Solution:1
It's doing an XPath query to find if the current document is an RSS feed by checking for the presence of certain XML elements. (Mozilla has a great run-down on XPath in JavaScript here)
Here are some examples:
Take look at the RSS Feed for this question:
<?xml version="1.0" encoding="utf-8"?> <feed .....
It's looking for that <feed>
element.
Or for example the slashdot.org main feed:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ...
It's looking for that <rdf:RDF>
element.
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon