文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>.NET: XmlElement - difference between Value, InnerText, and InnerXml(转)

.NET: XmlElement - difference between Value, InnerText, and InnerXml(转)

时间:2010-10-15  来源:酱板猪

<aNode anAttribute="Hello">   Some Big <b>Bad</b> text </aNode>    

 

This will give:

Value: null InnerText = "Some Big Bad text" InnerXml = "Some Big <b>Bad</b> text" OuterXml = "<aNode anAttribute="Hello">"Some Big <b>Bad</b> text"</aNode>

All of the above makes sense enough -- the only one that always left me a little bit wanting was the Value property that XmlElement inherits from XmlNode -- I invariably code sing that property, and then, realizing my mistake on first run, correct it to  point to InnerText.

The nagging question, really, for me, was why is it null? Doesn't make much sense to me.

 

I don't have an answer to it, but I did find this table today on the definition of XmlNode.Value:

 

The value returned by Value depends on the NodeType of the node:

  • CDATASection: the content of the CDATA Section.
  • Comment: the content of the comment.
  • Document: null.
  • DocumentFragment: null.
  • DocumentType: null.
  • Element: null. Use the XmlElement.InnerText or XmlElement.InnerXml properties to access the value of the element node.
  • Entity: null.
  • EntityReference: null.
  • Notation: null.
  • ProcessingInstruction: the entire content excluding the target.
  • Text: the content of the text node.
  • SignificantWhitespace: the white space characters (can consist of one or more space, carriage return, line feed, or tab chars).
  • Whitespace: the white space characters (can consist of one or more space, carriage return, line feed, or tab chars).
  • XmlDeclaration: the content of the declaration (that is, everything between <?xml and ?>).
排行榜 更多 +
房间毁灭模拟器最新版

房间毁灭模拟器最新版

休闲益智 下载
街头追逐者最新版

街头追逐者最新版

休闲益智 下载
弓箭手2内置作弊菜单

弓箭手2内置作弊菜单

休闲益智 下载