473,413 Members | 1,833 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,413 software developers and data experts.

XML + Deserialize = null object

Hi All,
I have XML:
<RegistryResponse status="Success" xmlns="urn:oasis:names:tc:ebxml-regrep:registry:xsd:2.1">
<AdhocQueryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1">
<SQLQueryResult>
<ObjectRef id="urn:uuid:425cb4ea-752c-4276-ae52-db295e8e7dc4" />
<ObjectRef id="urn:uuid:d9769b84-c48e-4381-bfd2-fe6e5c67cfc7" />
</SQLQueryResult>
</AdhocQueryResponse>
</RegistryResponse>


And I have the class generated by XSD tools:

[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType = true, Namespace = "urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1")]
[System.Xml.Serialization.XmlRootAttribute(Namespac e = "urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1", IsNullable = false)]
public partial class AdhocQueryResponse
{
private object itemField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Filt erQueryResult", typeof(FilterQueryResult))]
[System.Xml.Serialization.XmlElementAttribute("SQLQ ueryResult", typeof(RegistryObjectListType))]
public object Item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
}



[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e = "urn:oasis:names:tc:ebxml-regrep:rim:xsd:2.1")]
[System.Xml.Serialization.XmlRootAttribute("SQLQuer yResult", Namespace = "urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1", IsNullable = false)]
public partial class RegistryObjectListType : LeafRegistryObjectListType
{
private object[] items1Field;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Obje ctRef", typeof(ObjectRefType))]
[System.Xml.Serialization.XmlElementAttribute("Regi stryEntry", typeof(RegistryEntryType))]
[System.Xml.Serialization.XmlElementAttribute("Regi stryObject", typeof(RegistryObjectType))]
public object[] Items1
{
get
{
return this.items1Field;
}
set
{
this.items1Field = value;
}
}
}



[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e = "urn:oasis:names:tc:ebxml-regrep:rim:xsd:2.1")]
[System.Xml.Serialization.XmlRootAttribute("ObjectR ef", Namespace = "urn:oasis:names:tc:ebxml-regrep:rim:xsd:2.1", IsNullable = false)]
public partial class ObjectRefType
{
private string idField;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Dat aType = "ID")]
public string id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
}


I just post the related code, the full complete xsd are available at :
http://www.oasis-open.org/committees/regrep/documents/2.1/schema/rs.xsd
http://www.oasis-open.org/committees/regrep/documents/2.1/schema/query.xsd
http://www.oasis-open.org/committees/regrep/documents/2.1/schema/rim.xsd


I tried to deserialize the xml into object, the code is:
XmlNodeReader reader = new XmlNodeReader(doc.FirstChild.FirstChild);
XmlSerializer ser = new XmlSerializer(typeof(AdhocQueryResponse));
AdhocQueryResponse AQR;
AQR = (AdhocQueryResponse)ser.Deserialize(reader);
RegistryObjectListType ROLT = (RegistryObjectListType)AQR.Item;


There is no exception occoured, but my Item is all null...
I have no idea how to fix and trace the error.



Please help me.
Oct 2 '07 #1
0 1887

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Geoff | last post by:
Is it possible to pull a single node (element) out of a complex XML file, using SelectSingleNode(), and then deserialize that node to an object? Could someone please post, or point me to, a...
3
by: Just D. | last post by:
Can we deserialize an unknown object? The task is simple - we have many different types of objects stored in ArrayList. We can implement Serialize() method for each object and serialize all...
2
by: PCH | last post by:
I have 2 functions, one to serialize an object, and one to deserialize it. I can serialize just fine, the problem is when I try to deserialize it later... I get an error: {"Invalid...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
2
by: Ahmad Jalil Qarshi | last post by:
Hi! I have two applications A and B. I used the BinaryFormatter object to serialize and deserialize object of Structure "st" in my Applicaion "A". Now I tried to Deserialize that Object...
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
11
by: wpmccormick | last post by:
I've a complex problem: I'm deserializing a very long string of XML into a very large object foo: <foo> ....... <bar>sometimes a simple string is here</bar> ....... </foo>
0
by: connectpalm03-forum | last post by:
I have a class named (MyClassA) in ControlClasses.dll and was able to serialize it to database. Like below SaveTo(MemoryStream stream) { IFormatter formatter = new BinaryFormatter(); ...
9
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post by:
Hi, I have a schema that has an optional element, fieldTag4000Field. If the element is omitted from the XML request, when it is deserialized, it will be null when I check it - which is fine. ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.