开发者

Which Xml class to use for an array of XmlNode[]

I'开发者_如何学Cve generated some classes from an XSD which has worked fine, and I'm building up the the data and serializing it to XML, everything is working fine.

Except I have one property which is an array of XmlNode, and I can't for my life figure out what class to use. Not an XML expert.

The property in the class that was generated is as follows.

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string type
{
    get
    {
        return this.typeField;
    }
    set
    {
        this.typeField = value;
    }
}

And I've built up everything around it to this point:

timeInterval.AdditionalData = new[]
{
    new AdditionalDataType()
    {
        type = "DOECode",
        Any = new XmlNode[] { ... }
    }
 };

The expected Xml after serializing should be like:

<AdditionalData type="DOECode">11</AdditionalData>

What class can i put into the 'Any' to populate with a inner-text value, without changing the generated class.


Have solved the problem.

Solution was to create an XmlDocument, and create a node from the the document.

var node = (new XmlDocument()).CreateNode(XmlNodeType.Text, string.Empty, string.Empty);

Then assign the InnerText value:

node.InnerText = reason.ExportCode;

It generated the following.

<AdditionalData type="DOECode">TEST CODE</AdditionalData>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜