文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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 ?>).
排行榜 更多 +
无敌赛车王

无敌赛车王

赛车竞速 下载
多人汽车聚会

多人汽车聚会

赛车竞速 下载
漂移基地

漂移基地

赛车竞速 下载