Idea is to check RSS feed for <updated> </updated> if the RSS Updated header is updated matching the date that it is currently being run to then proceed to download.
Sample RSS Feed:
<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text"> Updates</title>
<subtitle type="html"><![CDATA[Latest updates]]></subtitle>
<link href="http://website/website.rss"></link>
<id>http://website</id>
<link rel="alternate" type="text/html" href="http://website/website.rss" ></link>
<link rel="self" type="application/atom+xml" href="https://website/site/download" ></link>
<logo>http://website/website</logo>
<updated>2020-03-28 T17:32:48+00:00</updated>
<entry>
<author>
<name>ueam</name>
</author>
<title type="text"><![CDATA[2.0.4516]]></title>
<link rel="alternate" type="text/html" href="https://website/site/download"></link>
<id>https://website/site/download</id>
<summary type="html"><![CDATA[<ul>
<li>Patched for March 23rd update</li>
<li>Fixed known bug JIRA</li>
</ul>]]></summary>
<content type="html"><![CDATA[]]></content>
<updated>2020-03-28 17:32:48</updated>
</entry>
<entry>
<author>
<name>Team</name>
</author>
<title type="text"><![CDATA[2.0.4516]]></title>
<link rel="alternate" type="text/html" href="https://website/site/download"></link>
<id>https://website/site/download</id>
<summary type="html"><![CDATA[<ul>
<li>
Patch for March 23rd update
</li>
</ul>]]></summary>
<content type="html"><![CDATA[]]></content>
<updated>2020-03-28 17:32:48</updated>
</entry>
<entry>
<author>
<name>Team</name>
</author>
<title type="text"><![CDATA[2.0.4514]]></title>
<link rel="alternate" type="text/html" href="https://website/site/download></link>
<id>https://website/site/download</id>
<summary type="html"><![CDATA[<ul>
<li>Fixed Bug</li>
Here
<updated>2020-03-28 17:32:48</updated>
is shown which if I was running today then would proceed to download since it matches the current day
The download would then called via
Invoke-WebRequest -uri https://website/site/download
I am just not sure how to parse the RSS to look at the "updated" and compare against current date and if date matches then proceed to download.
Update:
I tried the below
#Grab RSS
$rssString = Invoke-WebRequest "http://website/website.rss"
# convert rss to xml
$xml = [xml] $rssString
# select the <updated> node
$updateString = $xml.SelectSingleNode("/feed/updated").innerText
# convert string to date
$date = Get-Date $updateString
# compare to todays date
if($date.Date -eq (Get-Date).Date){
# proceed to download
}
You get this error:
Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Cannot convert null to type "System.DateTime"."
When you run
$updatestring
nothing is returned and is blank, seems that the updated node is not being read
RSS is xml, so treat it as such :)
The <updated> node immediately under the root <feed> seems to reflect the latest update, so grab that:
# convert rss to xml
$xml = [xml]$rssString;
# select the <updated> node
$updateString = $xml.SelectSingleNode("/feed/updated").innerText
# convert string to date
$date = Get-Date $updateString
# compare to todays date
if($date.Date -eq (Get-Date).Date){
# proceed to download
}
Related
I'm trying to write a script that will get the value of a node in multiple XML files.
Here is the XML structure :
<Report>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="lbReportName">
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Activity Report</Value>
</TextRun>
</TextRuns>
</Paragraph>
</Paragraphs>
</Textbox>
</ReportItems>
</Body>
</ReportSection>
</ReportSections>
</Report>
I use this script to search through the XML :
Select-XML -Path "N:\TEMP\XML\0.xml" –Xpath "//*[#Name='lbReportName']"
(Because the structure is not the same above the name "lbReportName").
Now, how can I get the value "Activity Report" ?
(After the name "lbReportName", the structure is the same for all XML files)
After the name "lbReportName", the structure is the same for all XML files
That makes it easier - since you already have a wildcard selector with an appropriate clause for the "common ancestor", it's as easy as just describing the rest of the path down to the <Value> nodes:
$ValueNodes = Select-Xml ... "//*[#Name='lbReportName']/Paragraphs/Paragraph/TextRuns/TextRun/Value"
# Let PowerShell's property enumeration behavior tackle the rest
$Values = $ValueNodes.Node.InnerText
Experimenting with Apple TV's TVML: I'm using a Product Template, and in the description field I'd like to add carriage returns, to make it look somewhat like a list.
Here is a simple example:
var Template = function() { return `<?xml version="1.0" encoding="UTF-8" ?>
<document>
<productTemplate>
<banner>
<infoList>
</infoList>
<stack>
<title>Big Title</title>
<description>
Line one
Line two
</description>
</stack>
</banner>
</productTemplate>
</document>`
}
I've tried \n, 
, 
 between the lines, and even something like this:
<![CDATA[
Line 1 <br />
Line 2 <br />
]]>
But none of these work. Is there a way to incorporate line breaks in TVML descriptions?
Having this code in a template.xml.js and loading it via the Presenter.js in the TVMLCatalog example from apple:
<stack>
<description>Insert your \n username (tipically your ID)</description>
</stack>
It renders
This also works:
var Template = function() {
const description = `
Line 1
Line 2
`.trim();
return `<?xml version="1.0" encoding="UTF-8" ?>
<document>
<productTemplate>
<banner>
<infoList>
</infoList>
<stack>
<title>Big Title</title>
<description>
${description}
</description>
</stack>
</banner>
</productTemplate>
</document>`
}
I am fairly new to webworks. I am trying to get the camera api to work and I keep getting the error:
Error in supported: TypeError: 'undefined' is not an object (evaluating 'blackberry.media.camera')
The page I am trying to use is on a hosted server. The code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<script language="javascript" type="text/JavaScript" >
function takePicture() {
try {
blackberry.media.camera.takePicture(successCB, closedCB, errorCB);
} catch(e) {
alert("Error in supported: " + e);
}
}
function successCB(filePath) {
document.getElementById("path").innerHTML = filePath;
//alert("Succeed: " + filePath);
}
function closedCB() {
// alert("Camera closed event");
}
function errorCB(e) {
alert("Error occured: " + e);
}
</script>
<title>Camera Test Widget</title>
</head>
<body >
<p>Test the Camera by pressing the button below</p>
<b>Take a Picture</b>
<div id="path"></div>
</body>
</html>
And my config.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="WebWorks Sample">
<access uri="http://www.flyloops.net/" subdomains="true">
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera" />
</access>
<name>Flyloops.net</name>
<description>This is a sample application.</description>
<content src="index.html"/>
</widget>
The page is hosted at: http://www.flyloops.net/mobile/bb/camera.html
I have been tearing my hair out for the past 3 hours...any help would be greatly appreciated.
If using PlayBook, make sure to have the correct element(s) defined
https://developer.blackberry.com/html5/apis/blackberry.media.camera.html
otherwise, if you are trying to access the blackberry.media.camera API from a remote website, then you need to white list that correctly in config.xml like this:
<access uri="http://www.flyloops.net/" subdomains="true">
<feature id="blackberry.media.camera" />
</access>
What device are you running? The code seems fine and it should work. You can get the eventlogs from the device and see what exceptions are being thrown.
Thanks
Naveen M
I am trying to build a tree from an xml file using jstree. I followed the documentation and looks like it is not working. Here is my code:
<html>
<head>
<title>Demo</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="C:\Users\jstree\jstree_pre1.0_fix_1\jquery.jstree.js"></script>
<Script Language="JavaScript">
$(function () {
$("#demo2").jstree({
"xml_data" : {
"ajax" : {
"url" : "books.xml"
},
"xsl" : "nest"
},
"plugins" : [ "themes", "xml_data" ]
});
});
</Script>
</head>
<body>
</body>
The XML is not formatted in a way that jsTree can include it.
http://www.jstree.com/documentation/xml_data
Two types of XML structures are supported - flat and nested:
<!-- FLAT -->
<root>
<item id="root_1" parent_id="0" state="closed">
<content>
<name><![CDATA[Node 1]]></name>
</content>
</item>
<item id="node_2" parent_id="root_1">
<content>
<name><![CDATA[Node 2]]></name>
</content>
</item>
</root>
<!-- NESTED -->
<root>
<item id="xml_1">
<content><name><![CDATA[Root node 1]]></name></content>
<item id="xml_2">
<content><name><![CDATA[Child node 1]]></name></content>
</item>
</item>
</root>
An alternative is to bring the XML document in and convert it into JSON, then transform it into a valid JSON or HTML data format.
Looks like container(#demo2) is missing. Try adding <div id='demo2'></div> under body tag.
Also make sure the jstree.js file is getting loaded correctly.
There is no such attribute for script called "language" (there may have been, but it's deprecated).
Place your code in script tags like the below code and try again
<script type="text/javascript">
//Your Code Here
</script>
Give a relative path instead of "url" : "books.xml". Replace it with the current path like "url" : "../Content/Xml/books.xml".
That might work.
Regards,
Amrutha
I'm trying to us NSXML to parse a user's channel from youtube. Parsing works ok, but I can't seem to figure out how to get the link from any specific movie as their are 5 exact the same nodes as following:
<link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=vLleTDikufefbk&feature=youtube_gdata" />
<link rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/vLleTDikededubk/responses" />
<link rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/vLlededTDikubk/related" />
<link rel="http://gdata.youtube.com/schemas/2007#mobile" type="text/html" href="http://m.youtube.com/details?v=vLldedeeTDikubk" />
<link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/users/node/uploads/vLlgrgreTDikubk" />
I've figured out how to get the attribute href from the node link. But since their are 5 different links I don't know how to only select the first one. Anyone got an idea?
Thnx you guys!!!
Found the solution already. I'll check if the link node has an attribute with alternate in it. If it does it has the right link node. Here is the code:
NSMutableArray *link; if ([elementName isEqualToString:#"link"]) if (!link) link = [[NSMutableArray alloc] init]; NSString *alternate = [attributeDict objectForKey:#"rel"]; if([alternate isEqualToString:#"alternate"]){ NSString *href = [attributeDict objectForKey:#"href"]; alternate = NULL; }