iPhone SDK 3 Programming : XML and RSS

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

In this section we discuss XML and then talk about RSS as one of its applications.

1. XML

Extensible Markup Language (XML) is a meta-language specification for exchanging information over the Internet. As a meta-language, it can be used to define application-specific languages which are then used to instantiate XML documents that adhere to the semantics of these languages.

The power behind XML is due to:

  • its extensibility, which allows anyone to define new XML elements

  • it being based on text, thus opening your application data to being used on any computing system.

To create/use an XML language, you need to identify the elements used in that language. An XML element uses:

  • begin-tag

  • text content

  • end-tag.

For example, the element person can appear in an XML document as:

content ...

Where <person> is the begin-tag and </person> is the end-tag. The content can itself be composed of text and other elements. For example:

<name>content of name...</name>
<address>content of address...</address>

If the text content of a given element contains characters that are difficult to include (e.g., "<", ">", "&", etc.), entities can be used for their representation. For example, "<" can be represented by the entity reference &lt;.

The fact that an XML document must have exactly one root element, and that any given element may contain other elements, allows us to naturally represent the XML document as a tree. For example, the following XML document can be represented as a tree (see Figure 1).

To work with an XML document, you need to be able to parse it (e.g., construct a tree representation of the document in memory as shown in Figure 1). There are several techniques for parsing and we will cover those shortly. libxml2 is an XML parser written in C that is available on, and recommended for use with, the iPhone OS. As we will see shortly, working with this library is very easy. You will be able to use a few function calls to the library in order to construct a tree similar to the one shown in Figure 1.

Figure 1. A tree representation of an XML document.

We need to remember that white spaces are not ignored in XML. In Figure 1, we show the white spaces as TEXT nodes. In libxml2, text nodes are of type XML_TEXT_NODE, while element nodes are of type XML_ELEMENT_NODE.

Now that we have an understanding of what XML is, let's look at one of its applications: RSS.

2. RSS

Really Simple Syndication (RSS) is an XML language used for sharing web content. As a content publisher, RSS gives you the power to inform your readers about new content on your information channel. RSS allows you, as a content consumer, to target your web activities towards information that you are actually interested in. For example, if you are mainly interested in health news, you do not want to spend a lot of time on or looking for health articles. What you want is a way for or to tell you when new health articles become available on their websites. The news channel can set up an XML instance file, based on the RSS language, advertising the newest health articles on its website. You use RSS reader software to subscribe to this XML file. The reader can refresh the copy of this XML file and present it to you. This scheme provides you with efficiency and also privacy as the website does not have to know your email address in order to inform you of new content. RSS can be thought of as both a push and a pull technology. The producer pushes filtered content that the consumer pulls.

Websites advertise the existence of specific channels using several icons. Figure 2 shows some of these icons. The universal feed icon (bottom icon) is gaining wide acceptance.

Figure 2. Several RSS icons. The universal feed icon (bottom icon) is gaining wide acceptance.

Let's illustrate the basics of an RSS feed through an example. The Nebraska State Patrol provides an RSS feed about absconded offenders. Individuals can subscribe to this channel to stay informed. Like everything else on the Internet, an RSS feed has a URL. For example, the URL for absconded offenders in the state of Nebraska is: Listing 1 shows a sample XML document of this feed.

Example 1. An example of an RSS document.
<?xml version ="1.0" encoding="UTF-093"?>
<rss version ="2.0">
Nebraska State Patrol | Absconded Offenders
The Nebraska State Patrol is currently
seeking information on the location of the
following individuals to determine if they are in
compliance with the Nebraska Sex Offender
Registration Act. This site is intended to
generate information on these individuals
and should not be used solely for the purpose
of arrest. Anyone with information
please call 402-471-8647.

<title>Nebraska State Patrol | SOR</title>

<title>Austen, Kate</title>
Absconded - Jefe de una loca mujer


Every RSS feed document starts with the following :

<?xml version="1.0" encoding="UTF-8"?>

This line indicates that this is an XML document. The version attribute is mandatory while the encoding attribute is not.

The root of the RSS feed is the rss element. This root element has only one child: the channel element. The channel element has three mandatory child elements: title, link, and description. In addition, it can hold several optional child elements such as: webMaster, image, copyright.

The mandatory elements are required for an RSS feed to be valid. However, valid does not necessarily mean useful. To be useful, the channel element should have one or more item child elements. Each story in an RSS feed file is represented by an item element. An item element contains three child elements: (1) a title element, (2) a link element, and (3) an optional description element. The reader presents to you the title of the story, its link, and, optionally, its description. If you are interested in the story, you click the link (a URL) to visit the web page of that story.

Now that we know the structure of an RSS feed document, let's use the libxml2 library to extract information from an RSS feed. First, we present a reader using DOM, then another one using SAX.

But before getting into the use of the libxml2 library, we need to do some additional configurations to the XCode project.

3. Configuring the XCode project

Follow these steps to configure your project to use ibxml2 library:

  • Add to Other Linker Flags of the project. Double-click on your project node. Select the Build tab and search for "other". Double-click on Other Linker Flags, and enter -lxml2. See Figure 3.

    Figure 3. Adding OTHER_LDFLAGS = -lxml2 to the project.
  • Add to Other Linker Flags of the target. You also need to repeat the previous step, but instead of adding the flag to the project, you need to add it to the target. Choose Project > Edit Active Target from the menu. Select the Build tab and search for "other". Double-click on Other Linker Flags and enter -lxml2. See Figure 4.

  • Add to the Header Search Path. You need to add the following line to the project:

    HEADER_SEARCH_PATHS = /usr/include/libxml2

    Figure 4. Adding OTHER_LDFLAGS = -lxml2 to the target.

    Double-click on the project node, and select the Build tab. Search for "header" and enter the value as shown in Figure 5.

  •  Windows Phone 8 : Making Money - Modifying Your Application, Dealing with Failed Submissions, Using Ads in Your Apps
  •  Windows Phone 8 : Making Money - Submitting Your App (part 3) - After the Submission
  •  Windows Phone 8 : Making Money - Submitting Your App (part 2) - The Submission Process
  •  Windows Phone 8 : Making Money - Submitting Your App (part 1) - Preparing Your Application
  •  Windows Phone 8 : Making Money - What Is the Store?
  •  BlackBerry Push APIs (part 3) - Building an Application that Uses the BlackBerry Push APIs - Checking the Status of a Push Request and Cancelling a Push Request
  •  BlackBerry Push APIs (part 2) - Building an Application that Uses the BlackBerry Push APIs - Unsubscribing From the Push System, Pushing Data to a Subscriber
  •  BlackBerry Push APIs (part 1) - Building an Application that Uses the BlackBerry Push APIs - BlackBerry Push API Domains , Subscriber Registration
  •  Windows Phone 8 : Phone Hardware - Speech Synthesis
  •  Windows Phone 8 : Phone Hardware - Speech Recognition
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us