How to get data from this kind of rss on ios ?
how to get data inside the <![CDATA[ ?
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Title 1</title>
<link>http://link1.com</link>
<description>Description 1</description>
<language>en-us</language>
<pubDate>Wed, 27 Feb 2013 12:38:54 EST</pubDate>
<lastBuildDate>Wed, 27 Feb 2013 12:38:54 EST</lastBuildDate>
<webMaster>webmaster#site.com (Hunny Bunny)</webMaster>
<item>
<title>item 1 title</title>
<link>http://item1 link</link>
<description><![CDATA[
<h2>My Item 2</h2>
<img src="http://itemi.com/image1.png" align="left"/>
]]></description>
<pubDate>Wed, 27 Feb 2013 12:10:40 EST</pubDate>
</item>
<item>
<title>item 2 title</title>
<link>http://item2.com/link</link>
<description><![CDATA[
<h2>My Item 1</h2>
<img src="http://itemi.com/image1.png" align="left"/>
]]></description>
<pubDate>Wed, 27 Feb 2013 12:10:40 EST</pubDate>
</item>
</channel>
</rss>
An option would be to use the NSXMLParser. I've used it with great success when parsing my RSS as well as ATOM feeds.
To examine information within <![CDATA[...]]>, you'll want to implement the following method of the NSXMLParserDelegate protocol:
- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock
Here's a terrific tutorial to get you started: Parsing XML data with NSXMLParser
Related
I have an issue where I'm trying to host a podcast via RSS feed myself, and I'm running into a strange issue. I validated my RSS feed and all of that, got everything working on iTunes on the desktop just fine. However, when I go to play that same podcast on my iPhone, I either get a "podcast is temporarily unavailable" error, or nothing at all. All of the information shows up fine and everything, but nothing will play. I made sure to check with my hosting service that Byte Range Requests are supported, and enabled. I don't know what the problem could be. The RSS looks like this (I edited some personal information out):
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Striate Cortex Testing...</title>
<description>This is a test of the Striate Cortex Podcasting System...</description>
<link>http://www.striatecortex.com</link>
<language>en-us</language>
<copyright>Copyright 2016</copyright>
<lastBuildDate>Tue, 16 Feb 2016 08:55:00 -0500</lastBuildDate>
<pubDate>Tue, 16 Feb 2016 08:55:00 -0500</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<webMaster>EMAIL (NAME)</webMaster>
<itunes:author>Striate Cortex</itunes:author>
<itunes:subtitle>PODCASTNAME is a show about interviewing other musicians, and talking about what life is like on the road.</itunes:subtitle>
<itunes:summary>PODCASTNAME is a show about interviewing other musicians, and talking about what life is like on the road. Something else to make this longer.</itunes:summary>
<itunes:owner>
<itunes:name>Striate Cortex</itunes:name>
<itunes:email>EMAIL</itunes:email>
</itunes:owner>
<itunes:explicit>Yes</itunes:explicit>
<itunes:image href="http://www.striatecortex.com/podcast.png"/>
<itunes:category text="Music">
</itunes:category>
<atom:link href="http://www.striatecortex.com/test.xml" rel="self" type="application/rss+xml" />
<item>
<title>Striate Cortex - PodcastName Test # 1</title>
<link>http://www.striatecortex.com/podcast/test</link>
<guid>http://www.striatecortex.com/test.mp3</guid>
<description>This is a description.</description>
<enclosure url="http://www.striatecortex.com/test.mp3" length="29184000" type="audio/mpeg"/>
<category>Podcasts</category>
<pubDate>Tue, 16 Feb 2016 08:55:00 -0500</pubDate>
</item>
</channel>
</rss>
Hi I need to convert the following input xml to the below mentioned output xml using xsl 2.0 version. I'm pretty new to xslt and I've tried using apply-templates and for-each-group to get a distinct collection of clients.
Input:
<?xml version="1.0" encoding="utf-8" ?>
<ITEM>
<allCounselling>
<ITEM>
<allAttendingPeople>
<ITEM>
<PersonKey>1</PersonKey>
</ITEM>
</allAttendingPeople>
<allSessions>
<ITEM>
<KEY></KEY>
<DATE>12 Dec 2014</DATE>
<allAttendedPeople>
<ITEM>
<PersonKey>1</PersonKey>
</ITEM>
<ITEM>
<PersonKey>2</PersonKey>
</ITEM>
</allAttendedPeople>
</ITEM>
</allSessions>
</ITEM>
</allCounselling>
</ITEM>
Required Output is
<Clients>
<Client>
<ClientId>1</ClientId>
</Client>
<Client>
<ClientId>2</ClientId>
</Client>
</Clients>
The PersonKey value is the ClientId and should be a distinct collection.
The other difficult part is that I have to filter the sessions also. If the session Item is within a given date range, then I should only out put the persons within that allAttendedPeople collection of those filtered sessions and then I have to traverse up to get the counselling item which contains those sessions and out put all attending people...I know it's pretty hectic :'(
Please help!
I have the xml structure xml like that:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">
<channel>
<item>
<comments>http://www.rtl.fr/actu/politique/laurent-gerra-imitant-nicolas-sarkozy-il-faut-barrer-la-
<slash:comments>0</slash:comments>
</item>
</channel>
</rss>
How can I get text in <slash:comments> tag.
I already try(Swift version):
elementItem.child("comments",inNamespace: "slash").
But it don't work.
As stated here, RaptureXML deletes namespaces, so you can access your content via
elementItem.child("comments")
I have done xml parsing before using some guides from Ray Wenderlich, but those are usually for when there are multiple items involved. I am working on having an app simply display weather conditions at a given time, and the feed's XML just has conditions for time checked. Here is the feed in question:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
<title>Yahoo! Weather - Montgomery, AL</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Montgomery__AL/*http://weather.yahoo.com/forecast/USAL0375_f.html</link>
<description>Yahoo! Weather for Montgomery, AL</description>
<language>en-us</language>
<lastBuildDate>Thu, 03 Jan 2013 11:55 am CST</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Montgomery" region="AL" country="United States"/>
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
<yweather:wind chill="43" direction="0" speed="5" />
<yweather:atmosphere humidity="66" visibility="10" pressure="30.26" rising="2" />
<yweather:astronomy sunrise="6:46 am" sunset="4:52 pm"/>
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
<link>http://weather.yahoo.com</link>
<url>http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif</url>
</image>
<item>
<title>Conditions for Montgomery, AL at 11:55 am CST</title>
<geo:lat>32.38</geo:lat>
<geo:long>-86.3</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Montgomery__AL/*http://weather.yahoo.com/forecast/USAL0375_f.html</link>
<pubDate>Thu, 03 Jan 2013 11:55 am CST</pubDate>
<yweather:condition text="Mostly Cloudy" code="28" temp="46" date="Thu, 03 Jan 2013 11:55 am CST" />
<description><![CDATA[
<img src="http://l.yimg.com/a/i/us/we/52/28.gif"/><br />
<b>Current Conditions:</b><br />
Mostly Cloudy, 46 F<BR />
<BR /><b>Forecast:</b><BR />
Thu - Partly Cloudy. High: 50 Low: 31<br />
Fri - Sunny. High: 57 Low: 35<br />
<br />
Full Forecast at Yahoo! Weather<BR/><BR/>
(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
]]></description>
<yweather:forecast day="Thu" date="3 Jan 2013" low="31" high="50" text="Partly Cloudy" code="30" />
<yweather:forecast day="Fri" date="4 Jan 2013" low="35" high="57" text="Sunny" code="32" />
<guid isPermaLink="false">USAL0375_2013_01_04_7_00_CST</guid>
</item>
</channel>
</rss>
Basically, all I need for the app is the current temperature and conditions, which under the item tag is contained within yweather:conditions tag. Using GDataXML, what would be simplest way of getting this info and setting an NSString equal to it?
Right now, I'm using some complex stuff from Ray's tutorial with asihttprequest and blocks for sorting and putting it all into an NSMutableArray, but I'm fairly certain it doesn't need be that complex now.
I like TBXML for straightforward parsing: http://www.tbxml.co.uk/TBXML/TBXML_Free.html .
I am working on a custom portal to VMware vCenter through the VMware Orchestrator API. I am using savon to query the SOAP API (WSDL) of Orchestrator and have that returning valid data... specifically an XML containing all the Virtual Machines.
What is the best/easiest way to capture the response into a Rails Model? The XML structure of the response is below...
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<findResponse xmlns="http://webservice.vso.dunes.ch">
<findReturn>
<totalCount>4</totalCount>
<elements>
<item>
<type>VC:VirtualMachine</type>
<id>vc.demo.local/vm-37</id>
<properties>
<item>
<name>displayName</name>
<value>FreeNAS</value>
</item>
<item>
<name>isTemplate</name>
<value>false</value>
</item>
<item>
<name>name</name>
<value>FreeNAS</value>
</item>
<item>
<name>connectionState</name>
<value>connected</value>
</item>
<item>
<name>state</name>
<value>poweredOff</value>
</item>
<item>
<name>vimHost</name>
<value>https://vc.demo.local:443/sdk</value>
</item>
<item>
<name>id</name>
<value>vm-37</value>
</item>
<item>
<name>dunesId</name>
<value>vc.demo.local/vm-37</value>
</item>
</properties>
<dunesUri>dunes://service.dunes.ch/CustomSDKObject?id='vc.demo.local/vm-37'&dunesName='VC:VirtualMachine'</dunesUri>
</item>
<item>
...
</item>
</elements>
</findReturn>
</findResponse>
</soapenv:Body>
</soapenv:Envelope>
You could pick out the few key attributes that you may want to query for (name, id, type) and then just store the rest of the XML as a clob or varchar or as a native XML type if your db supports it. Them you can read other values out in code when you need to.
I use the nokogiri gem to parse xml. With nokogiri you can call an xpath to get all elements with a certain parent tag. For example using your xml:
your_Model = Your_Model.new
docs = Nokogiri::XML(your.xml)
your_Model = docs.xpath('//item').map do |i|
{
#here you would need to map the objects of the xml to your model attributes so if your attributes were called, itemname, and itemvalue the code would be.
itemname => i.xpath('name').inner_text,
itemvalue => i.xpath('value').inner_text
}
your_Model.save!
Make sure you require the Nokogiri gem if you decide to go this route.
Hope it helps