Windows runtime 具有xsd.exe生成的序列化/无法访问System.Xml.XmlNode的WinRT

Windows runtime 具有xsd.exe生成的序列化/无法访问System.Xml.XmlNode的WinRT,windows-runtime,xmlserializer,xsd.exe,xmlnode,Windows Runtime,Xmlserializer,Xsd.exe,Xmlnode,我有通过xsd.exe生成的类(xsd.exe someschema.xsd/classes)。其中一个节点被声明为元素: <xs:element name="containsxmlelementsbeneath"/> 我可以在即时窗口中强制执行 ?((System.Xml.XmlNode[])elem.containsxmlelementsbeneath)[0].InnerXml 我没有IntelliSense,这在我尝试代码中的代码片段时是有意义的-该类似乎已从WinRT配置

我有通过xsd.exe生成的类(xsd.exe someschema.xsd/classes)。其中一个节点被声明为元素:

<xs:element name="containsxmlelementsbeneath"/>
我可以在即时窗口中强制执行

?((System.Xml.XmlNode[])elem.containsxmlelementsbeneath)[0].InnerXml
我没有IntelliSense,这在我尝试代码中的代码片段时是有意义的-该类似乎已从WinRT配置文件中删除-如果您只需要Windows.Data.Xml.Dom.IXmlNode,这很好-但在本例中不是这样

如何获取该元素的字符串表示形式?有没有办法“修复”xsd.exe生成的输出,使其使用Windows.Data.Xml.Dom进行序列化?(在我看来不是这样的)

我撞到了他们没想到的边缘案件吗

更新-尝试了以下操作(我知道,滥用动态):

这会导致“API'System.Xml.XmlNode[]”无法在当前平台上使用。”

我与另一个开发人员进行了(更长时间)的交谈-经过一些尝试和错误,我们找到了一个解决方案:

<xs:element ref="containsxmlelementsbeneath"/>

<xs:element name="containsxmlelementsbeneath">
</xs:element>
必须这样修改:

<containsxmlelementsbeneath>
  <somemore>
    ...
  </somemore>
</containsxmlelementsbeneath>
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class containsxmlelementsbeneath : IXmlSerializable
{
    [XmlIgnore]
    public string Text { get; set; }

    public System.Xml.Schema.XmlSchema GetSchema()
    {
        throw new System.NotImplementedException();
    }

    public void ReadXml(System.Xml.XmlReader reader)
    {
        Text = reader.ReadInnerXml();
    }

    public void WriteXml(System.Xml.XmlWriter writer)
    {
        throw new System.NotImplementedException();
    }
}
请注意,必须删除除XmlRoot之外的所有属性,否则会出现反射异常(只能为包含XmlElementsBenath的类型指定XmlRoot属性。请使用XmlSchemaProviderAttribute指定架构类型。)

最终结果:此节点及其所有子节点都是普通的旧字符串。不再有不可访问的XmlNode或XmlElement…

我与另一个开发人员进行了(更长时间的)聊天-经过一些尝试和错误,我们想出了一个解决方案:

<xs:element ref="containsxmlelementsbeneath"/>

<xs:element name="containsxmlelementsbeneath">
</xs:element>
必须这样修改:

<containsxmlelementsbeneath>
  <somemore>
    ...
  </somemore>
</containsxmlelementsbeneath>
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class containsxmlelementsbeneath : IXmlSerializable
{
    [XmlIgnore]
    public string Text { get; set; }

    public System.Xml.Schema.XmlSchema GetSchema()
    {
        throw new System.NotImplementedException();
    }

    public void ReadXml(System.Xml.XmlReader reader)
    {
        Text = reader.ReadInnerXml();
    }

    public void WriteXml(System.Xml.XmlWriter writer)
    {
        throw new System.NotImplementedException();
    }
}
请注意,必须删除除XmlRoot之外的所有属性,否则会出现反射异常(只能为包含XmlElementsBenath的类型指定XmlRoot属性。请使用XmlSchemaProviderAttribute指定架构类型。)


最终结果:此节点及其所有子节点都是普通的旧字符串。不再有不可访问的XmlNode或XmlElement…

如何在WinRT上反序列化XmlNode?我将使用xsd.exe生成类。在WinRT中包含这些类,然后在我反序列化之前就出现编译错误。如何在WinRT上反序列化XmlNode?我将使用xsd.exe生成类。在WinRT中包含这些类,然后在我反序列化之前得到一个编译错误。