Re: Deserialize Business Object



John,

Thanks for the response. What I am trying to do is return a business object
which I then use with XSLT to produce HTML. I am using an XMLReader in
conjunction with the SqlCommand object like so:

' Load data into Reader
Dim XMLR As System.Xml.XmlReader = sqlcom.ExecuteXmlReader

' Create an XmlSerializer
Dim Serializer As New XmlSerializer(GetType(Employee))

' Deserialize the data into the Projects instance
Dim Employee As Employee = CType(Serializer.Deserialize(XMLR),
Employee )

' Close reader
XMLR.Close()

Return Employee

The stored procedure associated with the SqlCommand object is returning data
using FOR XML. The Employee class has been created using XSD.exe.

Hopefully this has helped?


"John Saunders" wrote:

"Redowl" <Redowl@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:59376D5B-8845-4357-B618-672133CC224B@xxxxxxxxxxxxxxxx
Hi,

I am having an issue deserializing a business object from a SQL stored
procedure. I have created the class using the XSD tool and the resulting
XMLDATA schema but when I try to create the object I get an error message
<[Object] xmlns=''> was not expected.

As the XML being returned is an XML fragment due to not having a single
root
element I have previously got around this issue by adding another table to
the database which acts purely as the root element. However, I would like
to
do this properly rather than this bodge.

Very grateful for any advice. I am using SQL 2000 and version 1.1 of the
framework.

I'd need more detail from you to give a good answer. Therefore, here's a bad
answer:

Rather than add another table to the database, I'd suggest you add a root
node to your XML. Create a new XmlDocument, add the root element to it, then
add your fragment as a child node of the root element. That should do it.

John



.



Relevant Pages

  • Re: Deserialize Business Object
    ... I am having an issue deserializing a business object from a SQL stored ... As the XML being returned is an XML fragment due to not having a single ... Create a new XmlDocument, add the root element to it, then ... add your fragment as a child node of the root element. ...
    (microsoft.public.dotnet.xml)
  • Re: Editing XML
    ... I wonder how text and child nodes are distinguished in the XML text. ... The first is the processing instruction, which you'll typically ignore in XSLT. ... THe next is the element node named "tag" and the last is the text node. ... There is always exactly one root element in a valid XML document. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Help w/Self-Join Hierarchy Query
    ... > EXPLICIT then I may find the answer in there. ... > Then there is the ever popular employee - manager adjacency. ... > FOR XML SELF ...
    (microsoft.public.sqlserver.programming)
  • newbie: writing to xml and namespaces
    ... I'm having some issues when programmatically editing an XML file. ... XmlTextWriter and add the default namespace declaration when writing the ... appears other than in the root element. ...
    (microsoft.public.dotnet.languages.csharp)
  • Missing namespace in XML serialization
    ... We generated a VB wrapper class of this schema using the XSD.exe tool: ... Public Class Response ... Serializing an instance of Response class (defined as root element in the ... schema) we can obtain an XML document that correctly shows the namespace ...
    (microsoft.public.dotnet.xml)