Wednesday, October 23, 2013

XML Parsing

A major help with my XML parsing was Abbas Suterwala. Thank you, man. XML parsing was tricky for a programming newb (of which Butterfruit Labs has many).

Here is his introduction on parsing, which he said better than I can:

"We are in an age where, typically, an application cannot work in total isolation and does not have all the data it needs to do its work. It generally has to communicate to some other application–maybe over the internet–and read or send some data to it.
However, the applications with which your app communicates might not be developed using the same technology as yours. For smooth data exchanges between your app and some other application you might be exchanging data in an open format like Extensible Markup language or XML.
An XML document is a human readable text document that contains some starting and ending tags with attributes and data in those tags. Most of the languages and platforms have support for parsing and creating XML documents in them. Android also provides us APIs so that we can work and process XML documents in our app with ease and flexibility. In this article, we are going to see how you can work effectively with XML documents in your Android app."

When you are done, you can make a simple XML page like this (also Abbas' example)

<?xml version="1.0" encoding="UTF-8"?>
<products>
 <product>     
  <productname>Jeans</productname>
  <productcolor>red</productcolor>
  <productquantity>5</productquantity>
 </product>
 <product>     
  <productname>Tshirt</productname>
  <productcolor>blue</productcolor>
  <productquantity>3</productquantity>
 </product>
 <product>     
  <productname>shorts</productname>
  <productcolor>green</productcolor>
  <productquantity>4</productquantity>
 </product>
</products>

And the Parser can pull the info from it, in a form you can manipulate in your app.

Check out his XML Parsing page to learn just like I did!


1 comment:

  1. One of the things Parse analytics is accentuating most about the new SDK is its control over security. Parse says that the security upgrades in the SDK, in the same way according to protest Access Control Lists, have never been awhile ago accessible in a Javascript back-end administration.

    ReplyDelete