I'm learning how to use Node. At this time, I have an XML file that looks like this:
sitemap.xml
<?xml version="1.0" encoding="utf-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"><url><loc>http://www.example.com</loc><lastmod>2015-10-01</lastmod><changefreq>monthly</changefreq></url><url><loc>http://www.example.com/about</loc><lastmod>2015-10-01</lastmod><changefreq>never</changefreq></url><url><loc>http://www.example.com/articles/tips-and-tricks</loc><lastmod>2015-10-01</lastmod><changefreq>never</changefreq><article:title>Tips and Tricks</blog:title><article:description>Learn some of the tips-and-tricks of the trade</article:description></url></urlset>
I am trying to load this XML in my Node app. When loaded, I want to only get the url
elements that include the use of the <article:
elements. At this time, I'm stuck though. Right now, I'm using XML2JS via the following:
var parser = new xml2js.Parser();fs.readFile(__dirname +'/../public/sitemap.xml', function(err, data) { if (!err) { console.log(JSON.stringify(data)); }});
When the console.log
statement is executed, I just see a bunch of numbers in the console window. Something like this:
{"type":"Buffer","data":[60,63,120, ...]}
What am I missing?