Forums » API discussions » Query regarding API's response XML

Reply

Hi,

I need a little clarification on the XML response.

For example below is the part of the response I get:

<body>
<outline text="FT News" type="link" url="http://podcast.ft.com/rss/29/"/>
<outline text="ONE News" type="link" url="http://tvnz.co.nz/content/one_news_podcast_group/rss_itunes_mp4_skin.rss"/>
<outline text="TEDTalks News and Politics" type="link" url="http://feeds.feedburner.com/iTunesPodcastTTNewsPolitics"/>
<outline text="World News Australia Radio" type="link" url="http://feeds.feedburner.com/sbs_worldview"/>
</body>

Now I'm using SAX parser in JAVA.
In this inside the DefaultHandler class, I'm calling the method:

public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {}

Now here there are 2 variables, localname & qname. Right now I'm using localname to fetch tag names (viz. outline), but both variables are giving the same results as there is no namespace in the response yet.
But sometimes I've seen(not in this case but rarely) the localname comes empty string.

So please suggest should I continue using localname?
Or switch to qname.
Please note that if I use qname & you guys change the format of response XML & add namespaces then my code will not function.

Thank You
Rahul Saini

Hi Rahul,

It looks like you are using the API to deliver a response in OPML format. There is( or should be) a namespace in that response. That is <opml version="1.1" xmlns:podcastSearch= "http://digitalpodcast.com/podcastsearchservice/output_specs.html">

I think the URL is not working right and needs correcting.

The tag you want- "outline" is a standard part of the OPML spec and will not be namespaced.

Also, the API is versioned, so if you continue to use that version you should not have a problem with changes.

As for using qname or localname, I don't really know Java so I'm not in a position to help you choose.

If you're only concern is about the outline tag, that has been fixed for years and I cannot see any reason why we would add a namespace to that tag.

In reply to raul8