dbTalk Databases Forums  

XML and Array of Arrays

comp.databases.pick comp.databases.pick


Discuss XML and Array of Arrays in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ed Sheehan
 
Posts: n/a

Default XML and Array of Arrays - 04-22-2010 , 10:14 AM






I have a situation where a provider is using C# code to demonstrate XML
method requirements. In this case we have several elements, the first of
which states "array of selected items." This looks like the below text in
SOAP XML:

SOAP.XML:= '<in1>'
SOAP.XML:= '<string>2223</string>'
SOAP.XML:= '<string>2216</string>'
SOAP.XML:= '<string>2217</string>'
SOAP.XML:= '<string>11899</string>'
SOAP.XML:= '</in1>'

But then the next element specifies "array of arrays" to provide several
categories per item. So I need to generate XML to represent several
categories for each of the above items (2223, 2216, 2217, 11899).

I could guess that one element might look like:
<string>2223</string><cat1>C001</cat1><cat2>C002</cat2> etc, but I don't
know if this is kosher. Does anyone recognize this issue? Can you tell me
how to structure a "multivalued" XML array?

Thanks!

Ed

Reply With Quote
  #2  
Old   
Ed Sheehan
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 10:17 AM






Update: The category section is 'in1' to that implies a separate section. So
perhaps I just match the positions in in0 to in1?

Ed

"Ed Sheehan" <NOedsSPAM (AT) xmission (DOT) com> wrote

Quote:
I have a situation where a provider is using C# code to demonstrate XML
method requirements. In this case we have several elements, the first of
which states "array of selected items." This looks like the below text in
SOAP XML:

SOAP.XML:= '<in1>'
SOAP.XML:= '<string>2223</string>'
SOAP.XML:= '<string>2216</string>'
SOAP.XML:= '<string>2217</string>'
SOAP.XML:= '<string>11899</string>'
SOAP.XML:= '</in1>'

But then the next element specifies "array of arrays" to provide several
categories per item. So I need to generate XML to represent several
categories for each of the above items (2223, 2216, 2217, 11899).

I could guess that one element might look like:
string>2223</string><cat1>C001</cat1><cat2>C002</cat2> etc, but I don't
know if this is kosher. Does anyone recognize this issue? Can you tell me
how to structure a "multivalued" XML array?

Thanks!

Ed

Reply With Quote
  #3  
Old   
Ed Sheehan
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 10:18 AM



Sorry for this. The items section is in0. Category is in1.

Ed

"Ed Sheehan" <NOedsSPAM (AT) xmission (DOT) com> wrote

Quote:
Update: The category section is 'in1' to that implies a separate section.
So perhaps I just match the positions in in0 to in1?

Ed

"Ed Sheehan" <NOedsSPAM (AT) xmission (DOT) com> wrote in message
news:hqpp3v$pi6$1 (AT) news (DOT) xmission.com...
I have a situation where a provider is using C# code to demonstrate XML
method requirements. In this case we have several elements, the first of
which states "array of selected items." This looks like the below text in
SOAP XML:

SOAP.XML:= '<in1>'
SOAP.XML:= '<string>2223</string>'
SOAP.XML:= '<string>2216</string>'
SOAP.XML:= '<string>2217</string>'
SOAP.XML:= '<string>11899</string>'
SOAP.XML:= '</in1>'

But then the next element specifies "array of arrays" to provide several
categories per item. So I need to generate XML to represent several
categories for each of the above items (2223, 2216, 2217, 11899).

I could guess that one element might look like:
string>2223</string><cat1>C001</cat1><cat2>C002</cat2> etc, but I don't
know if this is kosher. Does anyone recognize this issue? Can you tell me
how to structure a "multivalued" XML array?

Thanks!

Ed



Reply With Quote
  #4  
Old   
mlucas@doxgroup.com
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 11:39 AM



Not 100% sure what you are trying to achieve, but I think what you are
after is:
<in1>
<string>
<name>2223</name>
<categories>
<category>C001</category>
<category>C002</category>
</categories>
</string>
<string>
<name>2216</name>
<categories>
<category>C002</category>
<category>C015</category>
</categories>
</string
</in1>

array of arrays is created by a tag set with a tag set inside that
repeats. The outer tag set doesn't contain a value itself, but a tag
with the value inside of it (i.e. <name>).

Marshall

Reply With Quote
  #5  
Old   
Ed Sheehan
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 12:14 PM



Would it mnake sense to do it this way? I'm just trying to fit in the in0
and in1 labels since they are used to represent items and categories.

<in0>
<string>2223</string>
<in1>
<string>C001</string>
<string>C002</string>
</in1>
<string>2216</string>
<in1>
<string>C002</string>
<string>C015</string>
</in1>
</in0>

<mlucas (AT) doxgroup (DOT) com> wrote

Quote:
Not 100% sure what you are trying to achieve, but I think what you are
after is:
in1
string
name>2223</name
categories
category>C001</category
category>C002</category
/categories
/string
string
name>2216</name
categories
category>C002</category
category>C015</category
/categories
/string
/in1

array of arrays is created by a tag set with a tag set inside that
repeats. The outer tag set doesn't contain a value itself, but a tag
with the value inside of it (i.e. <name>).

Marshall

Reply With Quote
  #6  
Old   
frosty
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 12:22 PM



Does the consumer of the XML really want _arrays_ or just nested values?

For the former, you might need 'type="array"' somewhere.

<things>
<thing type="array">
<thing>
<category>C001</category>
</thing>
<thing>
<category>C002</category>
</thing>
</thing>
</things>

Above is an array of (two) things, each of which has a (unique) category.

--
frosty


<mlucas (AT) doxgroup (DOT) com> wrote

Quote:
Not 100% sure what you are trying to achieve, but I think what you are
after is:
in1
string
name>2223</name
categories
category>C001</category
category>C002</category
/categories
/string
string
name>2216</name
categories
category>C002</category
category>C015</category
/categories
/string
/in1

array of arrays is created by a tag set with a tag set inside that
repeats. The outer tag set doesn't contain a value itself, but a tag
with the value inside of it (i.e. <name>).

Marshall

Reply With Quote
  #7  
Old   
Kevin Powick
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 12:29 PM



Hi Ed,

On Apr 22, 11:14*am, "Ed Sheehan" <NOedsS... (AT) xmission (DOT) com> wrote:
Quote:
But then the next element specifies "array of arrays" to provide several
categories per item.
Not really enough information to provide a direct answer, but aren't
SOAP arrays usually defined by the "SOAP-ENC:Array" type?

You mentioned having C# code available. Can't you just look at that
for the answer?

--
Kevin Powick

Reply With Quote
  #8  
Old   
Ed Sheehan
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 12:39 PM



I do have the code, but I'm not a C# programmer. I can see some references
to methods, but I don't know what that code is expecting back in the XML.
This is related to the last posting, where I wasn't sure how to invoke the
response method. Trial and error produced an answer, but now we're moving to
the next step.

Would seeing the code snippet help you to determine the XML structure?

Ed

"Kevin Powick" <kpowick (AT) gmail (DOT) com> wrote

Hi Ed,

On Apr 22, 11:14 am, "Ed Sheehan" <NOedsS... (AT) xmission (DOT) com> wrote:
Quote:
But then the next element specifies "array of arrays" to provide several
categories per item.
Not really enough information to provide a direct answer, but aren't
SOAP arrays usually defined by the "SOAP-ENC:Array" type?

You mentioned having C# code available. Can't you just look at that
for the answer?

--
Kevin Powick

Reply With Quote
  #9  
Old   
mlucas@doxgroup.com
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 01:05 PM



On Apr 22, 12:14*pm, "Ed Sheehan" <NOedsS... (AT) xmission (DOT) com> wrote:
Quote:
Would it mnake sense to do it this way? I'm just trying to fit in the in0
and in1 labels since they are used to represent items and categories.

in0
* * <string>2223</string
* * <in1
* * * * <string>C001</string
* * * * <string>C002</string
* * </in1
* * <string>2216</string
* * <in1
* * * * <string>C002</string
* * * * <string>C015</string
* * </in1
/in0
Depends on what you want in C# as a structure. I assume you are using
the MS XML object to tear it all back out in which case your structure
yields:

(assuming xml is the variable you pull the xml text into and parse)

xml.in0[0].string = "2223"
xml.in0[0].in1[0].string = "C001"
xml.in0[0].in1[1].string = "C002"
xml.in0[1].string = "2216"
xml.in0[1].in1[0].string = "C002"
xml.in0[1].in1[1].string = "C015"

Adjusting my XML slightly to be:
<in0>
<in1>
<name>2223</name>
<cats>
<cat>C001</cat>
<cat>C002</cat>
</cats>
</in1>
<in1>
<name>2216</name>
<cats>
<cat>C002</cat>
<cat>C015</cat>
</cats>
</in1>
</in0>

Yields:
xml.in0.in1[0].name = "2223"
xml.in0.in1[0].cats.cat[0] = "C001"
xml.in0.in1[0].cats.cat[1] = "C002"
xml.in0.in1[1].name = "2216"
xml.in0.in1[1].cats.cat[0] = "C002"
xml.in0.in1[1].cats.cat[1] = "C015"

Reply With Quote
  #10  
Old   
Ed Sheehan
 
Posts: n/a

Default Re: XML and Array of Arrays - 04-22-2010 , 01:13 PM



I think they're abstracting the names into these in0/in1... labels (for want
of a better word), so your first example, while not as elegant as your
second, seems to be the way they're going.

Thanks,

Ed

<mlucas (AT) doxgroup (DOT) com> wrote

On Apr 22, 12:14 pm, "Ed Sheehan" <NOedsS... (AT) xmission (DOT) com> wrote:
Quote:
Would it mnake sense to do it this way? I'm just trying to fit in the in0
and in1 labels since they are used to represent items and categories.

in0
string>2223</string
in1
string>C001</string
string>C002</string
/in1
string>2216</string
in1
string>C002</string
string>C015</string
/in1
/in0
Depends on what you want in C# as a structure. I assume you are using
the MS XML object to tear it all back out in which case your structure
yields:

(assuming xml is the variable you pull the xml text into and parse)

xml.in0[0].string = "2223"
xml.in0[0].in1[0].string = "C001"
xml.in0[0].in1[1].string = "C002"
xml.in0[1].string = "2216"
xml.in0[1].in1[0].string = "C002"
xml.in0[1].in1[1].string = "C015"

Adjusting my XML slightly to be:
<in0>
<in1>
<name>2223</name>
<cats>
<cat>C001</cat>
<cat>C002</cat>
</cats>
</in1>
<in1>
<name>2216</name>
<cats>
<cat>C002</cat>
<cat>C015</cat>
</cats>
</in1>
</in0>

Yields:
xml.in0.in1[0].name = "2223"
xml.in0.in1[0].cats.cat[0] = "C001"
xml.in0.in1[0].cats.cat[1] = "C002"
xml.in0.in1[1].name = "2216"
xml.in0.in1[1].cats.cat[0] = "C002"
xml.in0.in1[1].cats.cat[1] = "C015"

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.