Sax Itteration

CharlesIPTI

Active Member
Licensed User
Longtime User
Sorry for this Knube Question But ....
The Sax parser As I use the Parser_EndElement is it iterating over the XML results from my web service like for each element set ??

I get something like this:::

HTML:
<ArrayOfCLocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
  <CLocation>
    <DBID>75852</DBID>
    <LocationName>0103E01A1</LocationName>
    <SKU />
    <Shelf>1</Shelf>
    <Orientation>0</Orientation>
    <Short>false</Short>
    <Out>false</Out>
    <WalkSequence>0</WalkSequence>
  </CLocation>
  <CLocation>
    <DBID>75853</DBID>
    <LocationName>0103E01A2</LocationName>
    <SKU>F9719-AF1A</SKU>
    <Shelf>1</Shelf>
    <Orientation>0</Orientation>
    <Short>false</Short>
    <Out>false</Out>
    <WalkSequence>0</WalkSequence>
  </CLocation>
  <CLocation>
    <DBID>75854</DBID>
    <LocationName>0103E01D1</LocationName>
    <SKU />
    <Shelf>4</Shelf>
    <Orientation>1</Orientation>
    <Short>false</Short>
    <Out>false</Out>
    <WalkSequence>0</WalkSequence>
  </CLocation>
  <CLocation>



I dont have to manually create a loop to harvest all of the CLocations do I ?

I'm going to amke a CLocation TYPE and save the results into a list of these types..

Do I have to make a loop in the Parser_EndElement ??

If not the how to I persist each node into the types, property to save them into a list
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Thanks

Sorry Erel
thanks so much for your answer but...

I went out and studied the sax parser I see it hits the begin and end for each element allowing me to initialize my type in the begin section

initialize my type in the begin section and start building the type in the end section and finally add the type to my list when I reach ...well for my example the CLocation node..at the end element section


Just for clarity you "have" the element in the end Sub correct.
its not present in the begin sub when name = node name right ??
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
initialize my type in the begin section and start building the type in the end section and finally add the type to my list when I reach ...well for my example the CLocation node..at the end element section
This is correct.

Just for clarity you "have" the element in the end Sub correct.
its not present in the begin sub when name = node name right ??
This is also correct.

If you like I can write a small example that parses this XML.
 
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
No thank you

I have coded this portion already thank you.

presently I'm having a problem getting the web service to take my values for a insert. I've run this method from the web service and confirmed that the data is being persisted to SQl Server ,, (even thought it doesn't give me a confirmation boolean back for Success..) So I need to look at the specific string that its sending as Im getting a type error

Cannot convert 1p_OrderID=212508p_Message=Dev Test CRT p_LogLevel22 to System.Int32.

So theres obviously something wrong with my string
B4X:
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /cartdirectorservice.asmx/AddToCartLog HTTP/1.1
Host: xx.xx.xx.xxx
Content-Type: application/x-www-form-urlencoded
Content-Length: length

p_CartNumber=string&p_OrderID=string&p_Message=string&p_LogLevel=string

Thanks again you've been as usual very helpful
 
Upvote 0
Top