I have inner XML that looks like:
<approving xmlns="uz:rwc:fdu-92:1.0">
<fdu92>
<general num="25120001" date="25.12.2013" payment_kind="tehpd" sum="22200" />
<station code="370006" name="Test" road_short_name="Test" />
<cargo-owner code="7765" name="Test Subject" />
<payer code="7395392" name="Test Subject" />
<references>
<reference num="11111" doc_name="soma document">
<payments>
<payment code="158" subcode="001" name="Some work" reason="unknown" sum="22200" expended_count="1" />
</payments>
</reference>
</references>
</fdu92>
</approving>
<signature xmlns="uz:rwc:fdu-92:1.0">Many thousands of symbols</signature>
When I am trying to build classes from Xml by online tool xml to classes
it return Invalid Xml
.
Because it has
<signature xmlns="uz:rwc:fdu-92:1.0">Many thousands of symbols</signature>
Converting without tag
<signature xmlns="uz:rwc:fdu-92:1.0">Many thousands of symbols</signature>
gives good result
namespace Xml2CSharp
{
[XmlRoot(ElementName="general", Namespace="uz:rwc:fdu-92:1.0")]
public class General {
[XmlAttribute(AttributeName="num")]
public string Num { get; set; }
[XmlAttribute(AttributeName="date")]
public string Date { get; set; }
[XmlAttribute(AttributeName="payment_kind")]
public string Payment_kind { get; set; }
[XmlAttribute(AttributeName="sum")]
public string Sum { get; set; }
}
[XmlRoot(ElementName="station", Namespace="uz:rwc:fdu-92:1.0")]
public class Station {
[XmlAttribute(AttributeName="code")]
public string Code { get; set; }
[XmlAttribute(AttributeName="name")]
public string Name { get; set; }
[XmlAttribute(AttributeName="road_short_name")]
public string Road_short_name { get; set; }
}
[XmlRoot(ElementName="cargo-owner", Namespace="uz:rwc:fdu-92:1.0")]
public class Cargoowner {
[XmlAttribute(AttributeName="code")]
public string Code { get; set; }
[XmlAttribute(AttributeName="name")]
public string Name { get; set; }
}
[XmlRoot(ElementName="payer", Namespace="uz:rwc:fdu-92:1.0")]
public class Payer {
[XmlAttribute(AttributeName="code")]
public string Code { get; set; }
[XmlAttribute(AttributeName="name")]
public string Name { get; set; }
}
[XmlRoot(ElementName="payment", Namespace="uz:rwc:fdu-92:1.0")]
public class Payment {
[XmlAttribute(AttributeName="code")]
public string Code { get; set; }
[XmlAttribute(AttributeName="subcode")]
public string Subcode { get; set; }
[XmlAttribute(AttributeName="name")]
public string Name { get; set; }
[XmlAttribute(AttributeName="reason")]
public string Reason { get; set; }
[XmlAttribute(AttributeName="sum")]
public string Sum { get; set; }
[XmlAttribute(AttributeName="expended_count")]
public string Expended_count { get; set; }
}
[XmlRoot(ElementName="payments", Namespace="uz:rwc:fdu-92:1.0")]
public class Payments {
[XmlElement(ElementName="payment", Namespace="uz:rwc:fdu-92:1.0")]
public Payment Payment { get; set; }
}
[XmlRoot(ElementName="reference", Namespace="uz:rwc:fdu-92:1.0")]
public class Reference {
[XmlElement(ElementName="payments", Namespace="uz:rwc:fdu-92:1.0")]
public Payments Payments { get; set; }
[XmlAttribute(AttributeName="num")]
public string Num { get; set; }
[XmlAttribute(AttributeName="doc_name")]
public string Doc_name { get; set; }
}
[XmlRoot(ElementName="references", Namespace="uz:rwc:fdu-92:1.0")]
public class References {
[XmlElement(ElementName="reference", Namespace="uz:rwc:fdu-92:1.0")]
public Reference Reference { get; set; }
}
[XmlRoot(ElementName="fdu92", Namespace="uz:rwc:fdu-92:1.0")]
public class Fdu92 {
[XmlElement(ElementName="general", Namespace="uz:rwc:fdu-92:1.0")]
public General General { get; set; }
[XmlElement(ElementName="station", Namespace="uz:rwc:fdu-92:1.0")]
public Station Station { get; set; }
[XmlElement(ElementName="cargo-owner", Namespace="uz:rwc:fdu-92:1.0")]
public Cargoowner Cargoowner { get; set; }
[XmlElement(ElementName="payer", Namespace="uz:rwc:fdu-92:1.0")]
public Payer Payer { get; set; }
[XmlElement(ElementName="references", Namespace="uz:rwc:fdu-92:1.0")]
public References References { get; set; }
}
[XmlRoot(ElementName="approving", Namespace="uz:rwc:fdu-92:1.0")]
public class Approving {
[XmlElement(ElementName="fdu92", Namespace="uz:rwc:fdu-92:1.0")]
public Fdu92 Fdu92 { get; set; }
[XmlAttribute(AttributeName="xmlns")]
public string Xmlns { get; set; }
}
}
When I am trying to deserialize the object
DeserializeFromXmlElement<Approving>(FDU92Xml);
public static T DeserializeFromXmlElement<T>(XmlElement element)
{
var serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(new XmlNodeReader(element));
}
I get an error
xml document contains error
How to fix error? How to ignore signature
in deserialization process?