Trouble reading RSS data in AS3 - actionscript-3

I am trying to read a simple RSS feed in flash, but keep bumping into namespace issues. What's the proper way to get the content url from the following rss feed?
<rss version="2.0" xmlns:rbinl="http://reedbusiness.nl/rss/2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<item>
<media:content url="howtogetthis.jpg"/>
<title>This can be read from AS3</title>
</item>
</channel>
AS3 Code:
// this is working
xml.channel.item[0].title;
// this is not working
xml.channel.item[0].media.#url;

You need to reference the media namespace to access that content node with the url.
Here is an example:
//get a reference to the media namespace
var ns:Namespace = new Namespace("http://search.yahoo.com/mrss/");
//use ns::content to get a reference to a `content` node in the media namespace
xml.channel.item[0].ns::content.#url;
Keep in mind, namespaces prefix nodes. So the node name is content, not media.

Related

Is it possible to display an xml code on a page in ReactJS?

Say I have this xml code and I want to display it on my page:
<?xml version=\"1.0\" encoding=\"UTF-8\" ?> <rss version=\"2.0\">
<channel>
<title>W3Schools Home Page</title>
<link>https://www.w3schools.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS
Tutorial</title>
<link>https://www.w3schools.com/xml/xml_rss.asp</link>
<description>New RSS tutorial on W3Schools</description> </item> </channel> </rss>
I tried doing this, but the output is not what I want:
<div dangerouslySetInnerHTML={{ __html: this.state.body }} />
The output is like this:
https://www.w3schools.com Free web building tutorials https://www.w3schools.com/xml/xml_rss.asp New RSS tutorial on W3Schools
Which is not what I want. I want it to display the rss feed on my page without redirecting me, how can I do that? (Btw, the body is reading perfectly fine, so the problem is not from the body)
If you want to show the XML source code, then just output it as you would any other text:
<div>
{ this.state.body }
</div>
If you want to do sensible formatting, then you'll need to actually parse the XML and extract the data you care about from it. (There are JavaScript RSS parsers out there, you might want to look on NPM for a library you can use to do the heavy lifting for you).

How to Escape HTML URL via XML

So we just got a new phone system in the office. I am trying to figure out if there is a possibility to store contact photos of the various people in the company contact list outside of the individual phone storage. Currently we have to upload a photo for each person for each phone (since it is stored internally). We are able to import/upload a XML file to the phone. Below is where I am currently:
<?xml version="1.0" encoding="utf-8"?>
<contactData version="1.0">
<phonebook>
<contact sDisplayName="Test" sOfficeNumber="1111" sMobilNumber="2023929323" sOtherNumber="" Account_Id="8" Ring_Id="0" sGroupName="" photoCustom='..\i.imgur.com\ul8Hmru.jpg' photoSelect="0"/>
</phonebook>
<blacklist/>
<groupinfo/>
</contactData>
The images uploaded show as http://192.168.x.x/head_icon/imagename.jpg, when uploading the above xml, I got out of the head_icon folder and get it to show http://192.168.x.x/i.imgur.com/ul8Hmru.jpg. Is there a way to further escape the local IP so it goes and makes an attempt to fetch the image (allowing us to do a mass import of contacts storing the photos online somewhere)?
The value of the attribute photoCustom is using a relative URL, you need to specify an absolute URL (full path, starting http://)
<?xml version="1.0" encoding="utf-8"?>
<contactData version="1.0">
<phonebook>
<contact sDisplayName="Test"
sOfficeNumber="1111"
sMobilNumber="2023929323"
sOtherNumber=""
Account_Id="8"
Ring_Id="0"
sGroupName=""
photoCustom='http://192.168.x.x/i.imgur.com/ul8Hmru.jpg'
photoSelect="0"/>
</phonebook>
<blacklist/>
<groupinfo/>
</contactData>

How to display styled print out of XML on website

I am using some XML and I want to display it on site, But will prefer to display some styled version. Let's say in some boostrap table or something like that but somehow i have no clue how.
Example XML:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>W3Schools Home Page</title>
<link>http://www.w3schools.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS Tutorial</title>
<link>http://www.w3schools.com/rss</link>
<description>New RSS tutorial on W3Schools</description>
</item>
<item>
<title>XML Tutorial</title>
<link>http://www.w3schools.com/xml</link>
<description>New XML tutorial on W3Schools</description>
</item>
</channel>
</rss>
So let's say I have this XML, and i want to style it to table where will be:
Title | Link | Desc
W3Schools Home Page | http://www.w3schools.com/rss | New RSS tutorial on W3Schools
XML Tutorial | http://www.w3schools.com/xml | New XML tutorial on W3Schools
Can you give me some inditions or some can someone write example code for me to make it more clear.
I hope I don't ask for too much. Thank you all !!
Traditionally this done with an XSLT which is an instruction sheet for the browser to converts the xml into html automagically.
Checkout out:
https://greenbytes.de/tech/tc/xslt/
...for some great links to book and additional information.
There are some working examples at:
http://www.w3schools.com/xsl/xsl_examples.asp

Scala XML parsing with real-world HTML (with unmatched tag)

My application is trying to embed an html document into an XML document.
val xml =
<document>
<id> { getId } </id>
<content>
{ getContent }
</content>
</document>
getId is a simple function to return a new sequence number.
The issue is on getContent:
def getContent = {
val wrapped = "<wrap>"+article.content+"</wrap>"
XML.loadString(wrapped).child
}
As you may see, article.content return a String that stored the real-world HTML document.
The Scala.xml.XML.loadString function would parse it into XML and return a list of child and embeded into the xml val correctly.
However, this is working when only the html is valid, e.g. <body>Hello world</body>
In some of the article, it may appear: <body><strong>Hello world</body>
which lacking a closing tag of <strong> elem. (Yes, I can't just blame the user!)
In this case, it will throw an exception on this parsing and stop the application.
Is there any way I can either bypass the validation or simply embed the HTML as string within the XML document without parsing?
Please shed some light on this situation. Any suggestions are welcomed.
Both JSoup and TagSoup (amongst others) are suitable for passing HTML that isn't also well-formatted XML.
You'll have to decide which is best for your own use-case.

Adobe Air - StageWebView Meta Title

Is it possible to get the meta title of a .html document loaded over StageWebView?
My code:
webViewC.stage = cont.stage;
webViewC.viewPort = new Rectangle(cont.x,cont.y,cont.width,cont.height);
webViewC.loadURL("http://www.example.com/foobar.html");
Thanks. Uli
StageWebView is a very low level abstraction of core HTML rendering components on the target platform. As such, it provides very little interaction between ActionScript and the underlying HTML document.
If you are just looking for the documents' <title> element, then that is available through the webViewC.title getter once the Event.COMPLETE event has been raised. But if you are looking for the content of the <meta name='Title' content='...' /> element, then there is no way to access that through StageWebView.
I'm not quite sure what exactly you are trying to do, but you might be a URLLoader to retrieve the contents of the page, and then parse out the information that you want, then pass the raw HTML blob to webViewC.loadString()