• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

How can i covert XML string to Java Array in android

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys so i am trying to create a login right now the login is ok but what i am trying to do is convert this

to a java array so i can display the data upon login is there anyone who can help with this i also have this thread https://coderanch.com/t/617746/Android/Mobile/login-XML-array

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In simple way we can do like this for converting string to array

public static int[] strngToArr(String str)
{
int length = str.length();
int[] array = new int[length];
for (int i = 0; i < length; i++)
{
array[i] = Integer.parseInt(str.substring(i,i+1));
}
return array;
}

But in Android we have a separate file for string objects, where all string objects are stored.
For that you need to parse xml objects one by one then convert it into array.

I will try and get back to you.

Thanks
Atul Itankar

InfoCepts | www.infocepts.com
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Splitting strings and converting numbers is definitely not the way to do it: it will be brittle and a ton of work. You should use the built in mechanisms for XML parsing in Android. This link from the Android Developer's Network is a good place to get started: http://developer.android.com/training/basics/network-ops/xml.html
 
Reece Baron
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:Splitting strings and converting numbers is definitely not the way to do it: it will be brittle and a ton of work. You should use the built in mechanisms for XML parsing in Android. This link from the Android Developer's Network is a good place to get started: http://developer.android.com/training/basics/network-ops/xml.html



and thats for XML format i have ?
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Reece Baron wrote:

Steve Luke wrote:Splitting strings and converting numbers is definitely not the way to do it: it will be brittle and a ton of work. You should use the built in mechanisms for XML parsing in Android. This link from the Android Developer's Network is a good place to get started: http://developer.android.com/training/basics/network-ops/xml.html



and thats for XML format i have ?



The point of a library is that it works in a general way. It will work for your XML because it doesn't make any assumptions on the structure, other than being well-formed. It leaves you to determine what the structure of the XML means, while the library just parses out the data from the structure and gives it to you as it gets it.
 
Reece Baron
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:

Reece Baron wrote:

Steve Luke wrote:Splitting strings and converting numbers is definitely not the way to do it: it will be brittle and a ton of work. You should use the built in mechanisms for XML parsing in Android. This link from the Android Developer's Network is a good place to get started: http://developer.android.com/training/basics/network-ops/xml.html



and thats for XML format i have ?



The point of a library is that it works in a general way. It will work for your XML because it doesn't make any assumptions on the structure, other than being well-formed. It leaves you to determine what the structure of the XML means, while the library just parses out the data from the structure and gives it to you as it gets it.



Ok thanks mate now i just have to get the login to work with it once i have it all working
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The login and XML parsing should be two completely different things, they are not related. Even if you have to log in to download the XML, then you have three distinct steps (log in, download, parse). I would suggest not intermingling the three.
 
Reece Baron
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:The login and XML parsing should be two completely different things, they are not related. Even if you have to log in to download the XML, then you have three distinct steps (log in, download, parse). I would suggest not intermingling the three.



I have never done this before but i can see it will be hard to do
 
Oh the stink of it! Smell my tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic