XML技巧五则
点击次数:32 次 发布日期:2008-11-21 22:27:19 作者:源代码网
|
源代码网推荐源代码网整理以下技巧1 XmlNode.InnerText与.InnerXml的区别是:前者将内容中的<和>分别变成<和>,因此,希望将两段 XmlDocument 合并的程序只能使用
源代码网整理以下XmlDocumentFragment.InnerXml = XmlNode.OuterXml
源代码网整理以下技巧2
源代码网整理以下/XPath: string end-with
源代码网整理以下<xsl:for-each select="root/data[substring-after(@name,".")=
源代码网整理以下"Text" and string-length(value)>0]">
源代码网整理以下技巧3 一个XML文档在Load时如果失败,就是根本不合法;是否符合某个Schema(XSD)的要求则是有效性(valid)检查,方法是使用XmlValidatingReader对象的Schemas和ValidationType属性。
源代码网整理以下技巧4 XmlDataDocument类是从XmlDocument派生出来的,最重要的是增加了一个DataSet属性。不过这个类不是System.Xml提供的,而是System.Data提供的。对于总是要跟数据库打交道的应用程序来说,反正是要引用System.Data的,不如全部用XmlDataDocument。
源代码网整理以下技巧5 如何将XmlDataDocument对象中的DataSet更新保存到数据库中?DataSet本身有一个AcceptChanges方法,所以只需要:
源代码网整理以下xmlDataDoc.DataSet.AcceptChanges(); 源代码网供稿. |