I have an XML document that I am retrieving from a Web Service as a String.
I need to load this String into a locally accessible XMLDocument and a
custom class that I will Deserialize it into. I know how to do the
serialization, but am having trouble getting the string into the XMLReader.
Here is what I've been working with:

Dim oXML As New XmlDocument

Dim sXML As String = [WebMethod Request, returning XML]

oXML.LoadXml(sXML)

Dim xSer As New XmlSerializer(GetType(MyCustomClass))

Return xSer.Deserialize(???)

Now, I obviously need to create the XmlReader for deserailization, but how
can I get the contents of the XML document in there?

Re: XML pass around by Kirby

Kirby
Fri Aug 20 11:15:38 CDT 2004

Instead of using the XmlDocument, load the string into the XmlReader.
Here is a sample snippet:

MyServices.MySimpleService ws = new MyServices.MySimpleService();
string xml = ws.GetXml();

XmlReader reader = new XmlTextReader( xml, XmlNodeType.Document, null
);

XmlSerializer serializer = new XmlSerializer( typeof( person ));
person p = (person)serializer.Deserialize( reader );
reader.Close();

-KIRBY
--
Kirby Turner, MCSD, MCAD
www.whitepeaksoftware.com


On Thu, 19 Aug 2004 13:20:01 -0700, "Random" <cipherlad@hotmail.com>
wrote:

>I have an XML document that I am retrieving from a Web Service as a String.
>I need to load this String into a locally accessible XMLDocument and a
>custom class that I will Deserialize it into. I know how to do the
>serialization, but am having trouble getting the string into the XMLReader.
>Here is what I've been working with:
>
>Dim oXML As New XmlDocument
>
>Dim sXML As String = [WebMethod Request, returning XML]
>
>oXML.LoadXml(sXML)
>
>Dim xSer As New XmlSerializer(GetType(MyCustomClass))
>
>Return xSer.Deserialize(???)
>
>Now, I obviously need to create the XmlReader for deserailization, but how
>can I get the contents of the XML document in there?
>


Re: XML pass around by Random

Random
Fri Aug 20 15:14:30 CDT 2004

Wow! Works like a charm. Much better than the huge workaround I was doing
with the MemoryStream. Need help on a follow-up to this I have posted if
you have a chance to look.

"Kirby Turner" <kirby@whitepeaksoftware.com> wrote in message
news:2o8ci0h444iflu7eju1ba4td5i3ggg8ctj@4ax.com...
> Instead of using the XmlDocument, load the string into the XmlReader.
> Here is a sample snippet:
>
> MyServices.MySimpleService ws = new MyServices.MySimpleService();
> string xml = ws.GetXml();
>
> XmlReader reader = new XmlTextReader( xml, XmlNodeType.Document, null
> );
>
> XmlSerializer serializer = new XmlSerializer( typeof( person ));
> person p = (person)serializer.Deserialize( reader );
> reader.Close();
>
> -KIRBY
> --
> Kirby Turner, MCSD, MCAD
> www.whitepeaksoftware.com
>
>
> On Thu, 19 Aug 2004 13:20:01 -0700, "Random" <cipherlad@hotmail.com>
> wrote:
>
> >I have an XML document that I am retrieving from a Web Service as a
String.
> >I need to load this String into a locally accessible XMLDocument and a
> >custom class that I will Deserialize it into. I know how to do the
> >serialization, but am having trouble getting the string into the
XMLReader.
> >Here is what I've been working with:
> >
> >Dim oXML As New XmlDocument
> >
> >Dim sXML As String = [WebMethod Request, returning XML]
> >
> >oXML.LoadXml(sXML)
> >
> >Dim xSer As New XmlSerializer(GetType(MyCustomClass))
> >
> >Return xSer.Deserialize(???)
> >
> >Now, I obviously need to create the XmlReader for deserailization, but
how
> >can I get the contents of the XML document in there?
> >
>



Re: XML pass around by Kirby

Kirby
Mon Aug 23 08:08:43 CDT 2004

Point me to the follow up, i.e., posting subject, and I will see if I
can help.

On Fri, 20 Aug 2004 13:14:30 -0700, "Random" <cipherlad@hotmail.com>
wrote:

>Wow! Works like a charm. Much better than the huge workaround I was doing
>with the MemoryStream. Need help on a follow-up to this I have posted if
>you have a chance to look.
>
>"Kirby Turner" <kirby@whitepeaksoftware.com> wrote in message
>news:2o8ci0h444iflu7eju1ba4td5i3ggg8ctj@4ax.com...
>> Instead of using the XmlDocument, load the string into the XmlReader.
>> Here is a sample snippet:
>>
>> MyServices.MySimpleService ws = new MyServices.MySimpleService();
>> string xml = ws.GetXml();
>>
>> XmlReader reader = new XmlTextReader( xml, XmlNodeType.Document, null
>> );
>>
>> XmlSerializer serializer = new XmlSerializer( typeof( person ));
>> person p = (person)serializer.Deserialize( reader );
>> reader.Close();
>>
>> -KIRBY
>> --
>> Kirby Turner, MCSD, MCAD
>> www.whitepeaksoftware.com
>>
>>
>> On Thu, 19 Aug 2004 13:20:01 -0700, "Random" <cipherlad@hotmail.com>
>> wrote:
>>
>> >I have an XML document that I am retrieving from a Web Service as a
>String.
>> >I need to load this String into a locally accessible XMLDocument and a
>> >custom class that I will Deserialize it into. I know how to do the
>> >serialization, but am having trouble getting the string into the
>XMLReader.
>> >Here is what I've been working with:
>> >
>> >Dim oXML As New XmlDocument
>> >
>> >Dim sXML As String = [WebMethod Request, returning XML]
>> >
>> >oXML.LoadXml(sXML)
>> >
>> >Dim xSer As New XmlSerializer(GetType(MyCustomClass))
>> >
>> >Return xSer.Deserialize(???)
>> >
>> >Now, I obviously need to create the XmlReader for deserailization, but
>how
>> >can I get the contents of the XML document in there?
>> >
>>
>

--
Kirby Turner, MCSD, MCAD
www.whitepeaksoftware.com