[对不起,我的英语] 我有以下xml文档。该文档有很多嵌套,我只需要一个字段。因此,我认为没有必要创建多个对象来获取某些字段。
<cac:root>
<cac:a>
<cbc:b>
<ccc:c>
....
<czc:z>
here i'm
</czc:z>
....
</ccc:c>
</cbc:b>
</cac:a>
<cac:x>
some value 1
</cac:x>
<cbc:y>
some value 2
</cbc:y>
</cac:root>
我正在通过以下方式映射它
Some_object objectx = (some_object)serializer.Deserialize(some_reader);
...
[Serializable()]
[XmlRoot(ElementName = "root", Namespace = cac)]
public class Invoice_DTO
{
public const string cac = "some_namespace A";
public const string cbc = "some_namespace B";
public const string ccc = "some_namespace C";
....
[XmlElement(ElementName = "x", Namespace = cac)]
public string element_x { get; set; }
[XmlElement(ElementName = "y", Namespace = cbc)]
public string element_y { get; set; }
[XmlElement(ElementName = "z", ?????)]
public string element_z { get; set; }
}
请问有什么想法吗?