有一个xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<content>
<dmInfo dmid="id">
<dmCodeInfo>dmCodeInfo</dmCodeInfo>
</dmInfo>
<userID>userID</userID >
<userName>userName</userName >
</content>
定义了两个类
public class DmInfo
{
public string dmid { get; set; }
public string dmCodeInfo { get; set; }
}
public class Content
{
public DmInfo dmInfo { get; set; }
public string userID { get; set; }
public string userName { get; set; }
}
利用newtonsoft.json将xml转为Content类的时候如何能将xml节点
<dminfo dmid="id">
的属性dmid转为实体类的对应属性?
如果xml节点不带有属性,可以通过序列化反序列化将xml转为实体类,但现在的xml某节点带有属性,在转换时无法得到期望结果,得到的dminfo.dmid总是为null