Z
zemnon
Hello guys,
Here is a part of XML I am getting from a huge XML file:
<Task xmlns="http://al-lighting.com/alcheck/Namespace/AL">
<Name>String</Name>
<Script>
<ScriptFilename>String</ScriptFilename>
<ResultFilename>String</ResultFilename>
<Reportstyles>
<Name>String</Name>
<ReportstyleFilename>String</ReportstyleFilename>
<ReportFilenameExtension>String</ReportFilenameExtension>
<SchemaFilename>String</SchemaFilename>
</Reportstyles>
</Script>
</Task>
here is a class that I was generated with xsd.exe according to my xsd
file:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://mynamespace")]
[System.Xml.Serialization.XmlRoot("Task")]
public partial class ALTask
{
private ALTaskName nameField;
private ALScript scriptField;
private ALTaskComment commentField;
/// <remarks/>
public ALTaskName Name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
/// <remarks/>
public ALScript Script {
get {
return this.scriptField;
}
set {
this.scriptField = value;
}
}
/// <remarks/>
public ALTaskComment Comment {
get {
return this.commentField;
}
set {
this.commentField = value;
}
}
}
and I am trying to deserialize it to the class structure using this
code:
string xml = nodes.Current.OuterXml.ToString();
StringReader reader = new StringReader(xml);
XmlSerializer xs = new XmlSerializer(typeof(ALTask));
xs.Serialize(aa, testTask);
ALTask task = (ALTask) xs.Deserialize(reader);
The error shows that the {"<Task xmlns='http://mynamespace'> was not
expected."}
Does anyone know what the problem is? Because I also tried tp
deserialize the string "<Task><Name>String</Name></Task>" and it
works....
Please help, because I am very confused on this stage.
I will appreciate any help.
Best regards,
Zemnon
Here is a part of XML I am getting from a huge XML file:
<Task xmlns="http://al-lighting.com/alcheck/Namespace/AL">
<Name>String</Name>
<Script>
<ScriptFilename>String</ScriptFilename>
<ResultFilename>String</ResultFilename>
<Reportstyles>
<Name>String</Name>
<ReportstyleFilename>String</ReportstyleFilename>
<ReportFilenameExtension>String</ReportFilenameExtension>
<SchemaFilename>String</SchemaFilename>
</Reportstyles>
</Script>
</Task>
here is a class that I was generated with xsd.exe according to my xsd
file:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://mynamespace")]
[System.Xml.Serialization.XmlRoot("Task")]
public partial class ALTask
{
private ALTaskName nameField;
private ALScript scriptField;
private ALTaskComment commentField;
/// <remarks/>
public ALTaskName Name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
/// <remarks/>
public ALScript Script {
get {
return this.scriptField;
}
set {
this.scriptField = value;
}
}
/// <remarks/>
public ALTaskComment Comment {
get {
return this.commentField;
}
set {
this.commentField = value;
}
}
}
and I am trying to deserialize it to the class structure using this
code:
string xml = nodes.Current.OuterXml.ToString();
StringReader reader = new StringReader(xml);
XmlSerializer xs = new XmlSerializer(typeof(ALTask));
xs.Serialize(aa, testTask);
ALTask task = (ALTask) xs.Deserialize(reader);
The error shows that the {"<Task xmlns='http://mynamespace'> was not
expected."}
Does anyone know what the problem is? Because I also tried tp
deserialize the string "<Task><Name>String</Name></Task>" and it
works....
Please help, because I am very confused on this stage.
I will appreciate any help.
Best regards,
Zemnon