开发者

How can i deserialise two xml files with different tags but the same data

I have two xml files with the same data but different tags. I need to serialise them into an object. At first i tried to create the classes:

[XmlRoot(ElementName="ONIXMessage")]
public class ONIXMessage
{
    [XmlAttribute(AttributeName="release")]
    public string Release { get; set; }

    [XmlElement("Header")]
    public Header Header { get; set; }

    [XmlElement("Product")]
    public List<Product> Products { get; set; }        
}

However i'd need to create another class for the xml with different tags. Unless of course i find a better way to deserialise them. I currently have something like this:

XmlSerializer serializer = new
XmlSerializer(type);

FileStream fs = new FileStream(filename, FileMode.Open);
XmlReader reader = new XmlTextReader(fs);

return (ONIXMessage)serializer.开发者_如何学运维Deserialize(reader);

Hope i'm making sense.


How about XmlChoiceIdentifier?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜