I ran into a issue where I cant help myself and there wont come any help from the back end.
This is the story: I need to parse a XML from a URL.
The URL is: http://deliveroid.techhouse.sk/admin/restapi/company/62?userid=DFDJHGJDHGFFHH
Once you open it in a browser all looks good. Yet when I try to parse it within android (XmlPullParser) I get a error - the encoding is not right.
I have no idea what causes it and if its the server issue I wont have a chance to influence the situation..
Is there a way how to "force" the UTF-8 and make it parse able? Could someone show me how he would tackle this? One xml value lets say and you would save my day ..
Thank you
You can define encoding before parsing it.
XmlPullParser pullParser = Xml.newPullParser();
pullParser.setInput(theInputStream, "UTF-8");
Hope it helps
Related
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.
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.
What would the best approach to :
get html codes by calling url and displaying it in some views
if i would be editing the values against title tag, it must be automatically updated in the url link?
How to do this?
Check out the JSoup cookbook.
http://jsoup.org/cookbook/
This has a lot of good information in it and should be able to answer most of your questions.
You are probably looking for something along the lines of this: http://jsoup.org/cookbook/input/parse-body-fragment
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.
In android app, i want to send a php requeset, and am expecting a response in the form of xml, from the server.
Can anybody provide pointers in this case.
You can use XmlPullParser bundled with android to parse the response. To get the parser instance use this snippet:
XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser();
pullParser.setInput(...); //Set input source with response you parsing.
There are 3 methods for parsing XMl in android. See working with xml in android.
You may want to try out my XmlParsing library.
https://github.com/frenchie4111/XmlParser
Let me know if you have any problems with it.
Xstream is your friend http://x-stream.github.io/
XStream is a simple library to serialize objects to XML and back again.