473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

serialization XML problem

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
1 4336
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David K | last post by:
we are having a problem when trying to serilalize and deserialize DataTable When replacing the container to be ListArray or HashTable everything works fine The code is very straight forward (...
37
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
0
by: ktn | last post by:
Hi all, I'm a .NET beginner and I've got a problem on a program where I try to do an XML serialization. I get the following error : "An unmanaged exception of type...
2
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have...
0
by: umhlali | last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
5
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the...
2
by: Norman Chong | last post by:
Hiddeldi ho, I want to save an object so that I can use its content after I restart my program. I tried to solve this with serialization because someone told me that this is the correct way for...
4
by: mijalko | last post by:
Hi, I have inherited my class from System.Drawing.Printing.PrintDocument and I wish to serialize this object using XmlSerializer. And I get exception "There was an error reflecting type ...". If I...
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.