An RSS reader for Windows 8 is being created for a specific site. Everything works, except for the video [usually YouTube], as the website uses <object></object> to embed the video, not the <iframe> . the result is just a large block of empty objects wherever there is video.
My first instinct was to find and replace the <object></object> <iframe> tags and add the src attribute with the correct URL. I created a dummy application to check if this method will work, and the solution works if all you changed was static HTML.
Dummy app code:
<body> <div style="text-align: center;"> <object width="853" height="480" id="test"> <param name="movie" value="http://www.youtube.com/v/2rDs7W3WRIk?version=3&hl=en_US"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/2rDs7W3WRIk?version=3&hl=en_US" type="application/x-shockwave-flash" width="853" height="480" allowscriptaccess="always" allowfullscreen="true"></embed> </object></div>
Wrote and named a function below that really works. Want to do something similar to an XML document:
function setHTML5video() { var listOfSrcs = document.getElementsByTagName("embed"); for (var i = 0; i < listOfSrcs.length; i += 1) { var videoSrc = document.getElementsByTagName("embed")[i].getAttribute("src"); var newSrc = videoSrc.replace("/v/", "/embed/");
The end of the stub application code.
However, due to the lack of knowledge of the Windows 8 API, and despite the fact that he is responsible for the online response all day, I cannot find how to do the same with the XML feed that is downloaded from an external site. I probably missed something fundamental.
function itemInvoked(z) { var currentArticle = articlesList.getAt(z.detail.itemIndex); WinJS.Utilities.setInnerHTMLUnsafe(articlecontent, currentArticle.content); articlelist.style.display = "none"; articlecontent.style.display = ""; mainTitle.innerHTML = currentArticle.title; WinJS.UI.Animation.enterPage(articlecontent); }
When a user clicks on a thumbnail, the XML RSS feed for this article is pulled up and inserted into the file with id = "articlecontent". I want to change this channel before it is injected.
<section id="content"> <div id="articlelist" data-win-control="WinJS.UI.ListView" data-win-options="{ itemDataSource: mmoNewsPosts.ItemList.dataSource, itemTemplate: MMOItemTemplate }"></div> <div id="articlecontent"></div> </section>
Change, because there seems to be some confusion, I already have a loaded channel through WinJS.xhr:
function downloadMMOFeed(FeedUrl) { WinJS.xhr({ url: FeedUrl, responseType: "xml" }).then(function (rss) { pageTitle = rss.responseXML.querySelector("title").textContent; mainTitle.innerHTML = pageTitle; var items = rss.responseXML.querySelectorAll("item");