0

For the moment I'm tring ksoap2 but would like to use whatever the standard method is in the industry. I can access the 'Simple sample' (below) and write the values such as 'Frank' to the log using ksoap2 no problem, but the Complex Sample (below) has me stumped. I've seen lots of samples showing what I call 'Single level' xml but none that traverse down to 2 or more levels like the Complex Sample.

Any help?

---Simple Sample ---------------------------------------

<Category  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org        /2001/XMLSchema-instance" xmlns="http://ACCUMobileWS.org/">
  <CategoryId>99</CategoryId>
  <Name>Frank</Name>
  <Description>Prison Break</Description>
  </Category>
<Category>

-------Complex Sample------------------------------------------

<SuperCategory xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ACCUMobileWS.org/">
  <Categories>
    <Category>
      <CategoryId>99</CategoryId>
      <Name>Frank</Name>
      <Description>Prison Break</Description>
    </Category>
    <Category>
      <CategoryId>101</CategoryId>
      <Name>Jim</Name>
      <Description>Breakig Bad</Description>
    </Category>
  </Categories>
</SuperCategory>

The problem is geting into 2nd level i.e. the array of 'Category'

1 Answers1

1

I'm not very aware of ksoap2, but if you're going to be handling a lot of XML then you may want to check out the Simple Framework. I've used this extensively, and it's ability to easily turn XML into Java Objects makes things way easier for those that have many objects being handled.

If you're interested, you can check out this well-written tutorial for help setting it up.

Anthony Atkinson
  • 3,101
  • 3
  • 20
  • 22
  • Thanks for the feedback. I have taken your advice and researched Simple Framework. I have implemented the example tutotial that you suggested (altered the code to suit my complex xml sample above). I don't have any errors in the code however I am having problems when I get to the line "SuperCategory osd =serializer.read(SuperCategory.class, reader, false);" within the try/catch block. The code jumps from this line and executes the Error message with the catch block. Any reason why this might be happening? everything else is working perfectly. Thanks! – Ryan Gallagher Jun 13 '12 at 08:52
  • Got that working..just had to change a letter from lowercase to upper case to match xml file..I am having another problem now, I'm trying to parse a list that has no parent node I wonder if you could help me again, here is the link to my question http://stackoverflow.com/questions/11081941/trying-to-parse-xml-list-without-parent-node-using-simple-frame-work Thanks! – Ryan Gallagher Jun 18 '12 at 11:49