By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 1,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

serialization XML problem

P: n/a
There is an error in XML document (1, 2).
I used XML spy to create the XML and XSD. When I asked to
have the XML validated it said it was OK.

I used the .net SDK to generate the class. I have done
this before but this time I have no idea why I am getting
the error. Any ideas ?? THANKS !

<qcsttatus>
<manual sourcerootfolder="" manualname="">
<pmainfo pmapath=""/>
<stateaction qcdate="" qcwho=""/>
</manual>
<manual sourcerootfolder="" manualname="">
<pmainfo pmapath=""/>
<stateaction qcdate="" qcwho=""/>
</manual>
</qcsttatus>

This is my class that was generated:
//---------------------------------------------------------
---------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.0.3705.209
//
// Changes to this file may cause incorrect behavior
and will be lost if
// the code is regenerated.
// </autogenerated>
//---------------------------------------------------------
---------------------

//
// This source code was auto-generated by xsd,
Version=1.0.3705.209.
//
namespace qcstatus
{
using System.Xml.Serialization;
/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class manual {

/// <remarks/>
public pmainfo pmainfo;

/// <remarks/>
public stateaction stateaction;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string sourcerootfolder;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string manualname;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class pmainfo {

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string pmapath;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class stateaction {

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string qcdate;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string qcwho;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute("qcsttat us",
Namespace="", IsNullable=false)]
public class qcsttatus {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute
("manual")]
public manual[] manual;
}
}
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Andrew,

Firstly, let me confirm: The XML deserialization is giving you this error right? What is the type that you are sending to the XMLSerializer?
Since the root is qcstatus, sending that should work. It did when I tried. I got the same error you did if I set the type as 'manual' instead.
Maybe that's what's going wrong?...

So, doing the below on your xml file should work:

XmlSerializer serializer = new XmlSerializer(typeof(qcstatus.qcsttatus));
string fileName = @"c:\qcstatus.xml";
FileStream fs = new FileStream(fileName, FileMode.Open);
qcstatus.qcsttatus results = (qcstatus.qcsttatus)serializer.Deserialize(fs);
fs.Close();

(remember to put try catch blocks for File exception or deserialization exception)

HTH.
Thanks
Swati
--------------------
Content-Class: urn:content-classes:message
From: "andrewcw" <an************@boeing.com>
Sender: "andrewcw" <an************@boeing.com>
Subject: serialization XML problem
Date: Fri, 25 Jul 2003 14:51:46 -0700
Lines: 97
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNS9vGG2cqUjZQQRwCJrXSKBhXbcQ==
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:171942
NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

There is an error in XML document (1, 2).
I used XML spy to create the XML and XSD. When I asked to
have the XML validated it said it was OK.

I used the .net SDK to generate the class. I have done
this before but this time I have no idea why I am getting
the error. Any ideas ?? THANKS !

<qcsttatus>
<manual sourcerootfolder="" manualname="">
<pmainfo pmapath=""/>
<stateaction qcdate="" qcwho=""/>
</manual>
<manual sourcerootfolder="" manualname="">
<pmainfo pmapath=""/>
<stateaction qcdate="" qcwho=""/>
</manual>
</qcsttatus>

This is my class that was generated:
//---------------------------------------------------------
---------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.0.3705.209
//
// Changes to this file may cause incorrect behavior
and will be lost if
// the code is regenerated.
// </autogenerated>
//---------------------------------------------------------
---------------------

//
// This source code was auto-generated by xsd,
Version=1.0.3705.209.
//
namespace qcstatus
{
using System.Xml.Serialization;
/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class manual {

/// <remarks/>
public pmainfo pmainfo;

/// <remarks/>
public stateaction stateaction;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string sourcerootfolder;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string manualname;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class pmainfo {

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string pmapath;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespac e="",
IsNullable=false)]
public class stateaction {

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string qcdate;

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string qcwho;
}

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute("qcsttat us",
Namespace="", IsNullable=false)]
public class qcsttatus {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute
("manual")]
public manual[] manual;
}
}

--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified
at http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they
originated.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.