Inserting XML structure into a XML file

joneden

Active Member
Licensed User
Longtime User
Hi,

I'm using XMLBuilder to build an XML file (to send upto a webservice). I need to insert a set of prebuilt XML snippets into the file.

How do I insert precreated XML into the file retaining it's structure?

My code at the moment is as below: The issue lies on the line that at the moment has .text(obj.... The XML data is stored in a db.

B4X:
For i = 0 To objCursor.RowCount - 1
   objCursor.Position = i
   objXMLBuilder.element("UploadEntry") _
      .attribute("ID",objCursor.GetString("ID")) _
      .element("ActionXML") _
            .text(objCursor.GetString("XMLString"))
Next

Regards,

Jon
 

joneden

Active Member
Licensed User
Longtime User
Hi Erel,

Sure, below is a sample of what I want
<UploadEntry ID="43">
<ActionXML>
<ReactiveTask ID="8700">
<Notes>Here are some
notes that need to
be saved against the task
</Notes>
</ReactiveTask>
</ActionXML>
</UploadEntry>
<UploadEntry ID="44">
<ActionXML>
<PostTask ID="875846795">
<Delivered>17 Sep 2012 09:21:02</Delivered>
<DeliveredBy>Roger Smith</Delivered>
</ReactiveTask>
</ActionXML>
</UploadEntry>

The UploadEntry tag allows the server to confirm that it has managed to utilise the XML in the ActionXML tag. Then once all are processed some XML will come back from the server with a list of all the UploadEntries that can be deleted from the database on the device. Any that for some reason can't be uploaded will then be visible on the device.

The ReactiveTask and PostTask XML in the example are generated when someone closes the tasks on the device, then come upload time I want their XML to be inserted into this the rest of it.

Obviously I can create this using standard strings but I wanted to generate in a more concise and elegant way using the toolkit that's already there...

Cheers,

Jon
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Hi Erel,

That's what I thought. I'm still using my snippet of XML for the middle and just using stringbuilder around it.

I did see a java lib somewhere that extended the XMLBuilder functionality. Maybe I'll see if I can convert that as an experiment :)

Regards,

Jon
 
Upvote 0
Top