Parsing an XML to a tableview - android

I'm really new to developing on Android. I started learning developing due to an application we need to make. I also have a deadline.
So, I wonder if anyone could help this hopeless rookie out :P That'd be so great.
I need the values of the keywords (lag, kamper, mal, poeng, maldiff, status, posisjon, hb, malH, MalB, E, V, U, T, J, kn, id) to be put into a tableview. Not all of them but many.
If someone got a guide or tutorial that a newbie could follow, it would be greatly appreciated.
Or if someone could set it up for me so I could fill in the rest.
I know I'm way over my head with this stuff but if there's any chance I can get it done, I will try.
Here's an URL to a forum I posted the XML in.
http://www.anddev.org/other-coding-problems-f5/parsing-xml-requesting-guide-for-new-beginner-t55538.html
How do I add XML file? Copy-paste doesn't work.

use jaxp library to parse xml. Inthat xpath concept is there. using this we can easily parse xml.

If I got your problem then according to me there is no method to show data in TableView directly while parsing the xml file, you need to parse XML file and store data(say key - value pair or in bean class) and then you need to write code to set your TableView with parsed vales.

Related

How to get the inner tags from an XML file?

I'm sitting there for quite a while now, trying to process my xml file (similar to the one below). I want to check all tags, if is equal to a variable, and if so, then running readEntry() on the tag.
I followed this example: https://developer.android.com/training/basics/network-ops/xml.html
I also found this Article(Difficulty with XML nested tags with XMLPullParser in Android deals with this topic.
I have already tried a few things but get either nothing or XmlPullParserException.
A Example of my XML:
<VpMobil>
<Kopf>
...
</Kopf>
<FreieTage>
...
</FreieTage>
<Klassen>
<Kl>
<Kurz>5</Kurz>
<Pl>
<Std>
<St>1</St>
<Fa>Fa1</Fa>
<Le>NAME</Le>
<Ra>1009</Ra>
<Nr>131</Nr>
<If/>
</Std>
<Std>
<St>2</St>
<Fa>Fa2</Fa>
<Le>NAME</Le>
<Ra>1004</Ra>
<Nr>132</Nr>
<If/>
</Std>
</Pl>
</Kl>
<Kl>
<Kurz>6</Kurz>
<Pl>
<Std>
<St>1</St>
<Fa>Fa2</Fa>
<Le>NAME</Le>
<Ra>1046</Ra>
<Nr>131</Nr>
<If/>
</Std>
<Std>
<St>2</St>
<Fa>Fa3</Fa>
<Le>NAME</Le>
<Ra>1012</Ra>
<Nr>132</Nr>
<If/>
</Std>
</Pl>
</Kl>
</Klassen>
</VpMobil>
I would be very grateful if someone could explain to me how I can achieve this. Thanks in advance
You can use Jackson library to parse XML, it is as easy as parsing Json File. this tuto will help you to figure out.
However, bescause it is is a nested xml, you will need some nested POJOs to achieve parsing.
After a few more unsuccessful attempts, I got the idea to convert the XML into a JSON (Convert XML to JSON object in Android) and continue working with it. That worked then.

XML or JSON Data to View mapper in Android

I have some sort of simple mobile shopping section inside my app. I get XML or JSON from server and want to put name/description/price/currency/etc to corresponding views. I really don't want to parse all XML myself and prefer to use some syntax like ["products.product.price" -> R.id.priceTextView] to map xml/json data to Android views.
I googled a little bit but failed to find a good way to do this. Do anybody know some lib or maybe Android class doing that?

How to present parsed JSON in readable format to users?

So I have JSON, I parsed in and it's sitting there. From my code below it looks like I have put everything into an ArrayList but then what? I mean for example I need the "title" of each JSON object to be an onClick on the first page, is that possible?
Essentially my onPostExceute() is empty/not doing much. Eventually I need to separate each object into it's own page via the onlicks I'm mentioning, but I think I can do that by separating the JSONObjects...? guess I'll come to that when I can.
If I want to separate things should I even be using an ArrayList? It's just what I used for a server test I ran with different code.
Would really appreciate some help. Basically stuck at the last hurdle is how I perceive it. Maybe I'm wrong though. The logs see that the JSON is showing up as one big chunk.
Edit: Removed my code, this is more of a theory question. ListView being the best thing to go with.
yes you can make spearate arraylist for them..and can store them in diferent listviews...on google click you can open new listview showing id and link for google ..and same you can do for microsoft and your other trem.And using onItemClick is a gud option,you can easily get the index of item clicked//

Trying to pull API into LinearLayout Android APP

I am a beginner of Android apps and am using Eclipse. I have found some larger samples of pulling APIs but I cannot find a simple one to get started with. I simply want to pull from an XML file on the web (by using an API KEY) and throw it in a LinearLayout (Vertical). I can then go from there, anyone know of any? Below is a sample of my XML:
<xmldata>
<Products>
<ProductCode>ITI-GR12</ProductCode>
<ProductName>Granada 9-3/4" Narrow Rim Platter</ProductName>
<ProductPrice>64.4000</ProductPrice>
</Products>
</xmldata>
I am assuming you are looking for mechanisms which help you to parse XML and extract data from it...Voila here is a link to get you started with different ways of doing it...
http://www.ibm.com/developerworks/opensource/library/x-android/
Good luck!
your question is not easy as you will have quite a lot of programming to achieve what you want.
Here are the steps :
read your data using sax
fill a data structure of your own (build a
class, data members will be filled by
previous parsing)
build an activity, use a layout you define to
show all UI fields you think you need
to display your data
fill the content of each view using the data
structure you filled on step 2.
If you are a beginner, I suggest you first understand steps 3 and 4, having fun with UIs, then try to understand how you could download your file, parse it and fill some data class to provide content for the views.
Regards,
Stéphane

calling xml to Android

I have list of records in xml format from my local host "http:localhost:810/Service1.svc/leb/GetAllCustomers"
Can I call this to android and list it in Textview or Spinner or in EditTextView or in any of the controls in android?
You should parse this xml file using SAX parse or Dom Parse in android and collect date in arrays/list/map according to your requirement here i am post some link to you get more information form there and get your ASAP.
http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser
http://www.androidpeople.com/android-xml-parsing-tutorial-%E2%80%93-using-domparser
I hope this is very helpful to you.
Some links here for you.
1) Multithreading for Performance
to help you understand, how to download a file (example shows downloading an image) via AsyncTask.
2) Working with XML in Android
to help you parse your xml. Check these out. Good luck!
Yes you can do that.
Use Intent which takes URL as an argument.
In the URL you can mention the location/URI of your source.
Then, you can parse it to a string and store it.
Later, use ArrayAdapter to populate.
I can get you code if this is what you are trying to do.

Categories

Resources