Below is my code that works great so far but I would like to reformat the date
that is pulled from the content:
let $date := data($doc//div/h2)
the date is retrieved as "July 30, 2012" but I would like to convert it to
rss2 RFC 822 format "Mon, 30 Jul 2012 0:00:01 GMT"
Some direction would be greatly appreciated.
<template><![CDATA[ <rssversion="2.0"><channel><title>News</title><lastBuildDate>${sys.datetime("EEE, dd MMM yyyy HH:mm:ss z")}</lastBuildDate><language>en-us</language> ]]></template><loopitem="articleUrl"index="i"><!-- collects URLs of all articles from the front page --><list><xpathexpression="//a[1]/@href"><html-to-xml><httpurl="${startUrl}"/></html-to-xml></xpath></list><!-- downloads each article and extract data from it --><body><empty><var-defname="item_link"><template>${sys.fullUrl(startUrl,articleUrl)}</template></var-def></empty><xquery><xq-paramname="doc"><html-to-xml><httpurl="${sys.fullUrl(startUrl,articleUrl)}"/></html-to-xml></xq-param><xq-paramname="link"type="string"><varname="item_link"/></xq-param><xq-expression><![CDATA[ declare variable $doc as node() external; declare variable $link as xs:string+ external; let $date := data($doc//div[@id="main"]/h2[@class="date"]) let $title := data($doc//div[@id="main"]/h1) let $text := data($doc//div[@id="main"]/p[1]) return<item><link>{data($link)}</link><title>{data($title)}</title><pubDate>{data($date)}</pubDate><description>{data($text)}</description> </item> ]]></xq-expression></xquery></body></loop><![CDATA[ </channel></rss> ]]>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are there any examples of changing the date format from the scrape to the
output file?
Thanks
Jim
You can change it using javascript date functions. Give example what you want
to do.
Below is my code that works great so far but I would like to reformat the date
that is pulled from the content:
let $date := data($doc//div/h2)
the date is retrieved as "July 30, 2012" but I would like to convert it to
rss2 RFC 822 format "Mon, 30 Jul 2012 0:00:01 GMT"
Some direction would be greatly appreciated.