Thanks for that I thought about using a structure but the only problem
I envisaged was that there <Commands> section is variable, and could
contain 10, 20, 34 etc.. so if I used your suggestion how would that
work.
If i created a <command> structure within a <player> structure when it
arrived would it contain the correct numnber of elements, or do i have
to specify at design time, that a <player> structure contains say a
maximum of 40 <command> structures.
Thanks
Tony
> Hi Tony,
>
[quoted text clipped - 46 lines]
> and let XmlSerialization deal with it. That would give you a simple object
> model to deal with instead of the raw xml.
Tomas Restrepo \(MVP\) - 16 Jul 2003 02:32 GMT
Hi Tony,
> Thanks for that I thought about using a structure but the only problem
> I envisaged was that there <Commands> section is variable, and could
[quoted text clipped - 4 lines]
> to specify at design time, that a <player> structure contains say a
> maximum of 40 <command> structures.
No, no problem. It's just an array, that's all. Here's a simple example of
what I mean (in C#, but should be a breeze to convert to VB), that also
shows how to use the Xml Serialization attributes to tweak the conversion
process a little:
using System.Xml;
using System.Xml.Serialization;
using System.Web.Services.Protocols;
[ XmlType(Namespace="http://whatever.ns.i.want.org/") ]
[ XmlRoot("Player", Namespace="http://whatever.ns.i.want.org/") ]
public class Player
{
public PlayerInformation Information;
public Command[] Commands;
}
public class PlayerInformation
{
public string PlayerID;
public string PlayerName;
}
public class Command
{
[ XmlAttribute() ]
public string CurPos;
[ XmlAttribute() ]
public string NewPos;
[ XmlAttribute() ]
public string Colour;
[ XmlText ]
public string Value;
}
[ WebMethod ]
[ SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare) ]
public void WhateverMethod(Player player)
{
// do what you want.
}
Nifty, isn't it?
--
Tomas Restrepo
tomasr@mvps.org