易截截图软件、单文件、免安装、纯绿色、仅160KB

Autodesk Vault API 类的Xml Serialization攻略

译自Vault API帮助文档中一篇 Doug Redmond写的knowledgebase article. Doug's 博客是 It's All Just Ones and Zeros
你也许不知道所有Vault API 类都可以 XML 序列化 - 这意味着很容易把API对象转换为 XML 文本,反之亦然。 
很多种情况下可以使用此功能,例如:
它可以帮助您调试代码。如果您具有大量数据的对象,将该对象存为XML格式方便研究。
如果您向ADN提交问题,可以将XML序列化的对象作为您的问题说明的一部分。
存储信息供以后使用。只需记住,此信息在下一版本中可能会更改。
您可以使用XML序列化后的信息作为检测对象是否已发生变更的参照物。例如您编写了一个设置生命周期的程序,您希望您的程序检测到是否有人干预了生命周期设置。
下面是一些Vault API XML 序列化的示例代码:
C#:
private bool DidItChange(LfCycDef def)

    // serialize the object 
    StringBuilder currentXML = new StringBuilder(); 
    XmlSerializer serializer = new XmlSerializer(typeof(DocEx.LfCycDef)); 
    using (TextWriter writer = new StringWriter(currentXML)) 
    { 
        serializer.Serialize(writer, def); 
    } 
    // read in the stored XML 
    string originalXML = System.IO.File.ReadAllText("correct.xml");  
    // now all you have to do is compare the two 
    return (originalXML != currentXML.ToString()); }
VB:
private function  DidItChange(def as LfCycDef ) as boolean
    ' serialize the object
    dim currentXML as StringBuilder  = new StringBuilder()
    dim serializer as XmlSerializer  = new XmlSerializer(GetType(LfCycDef))
    using writer as TextWriter = new System.IO.StringWriter(currentXML)
        serializer.Serialize(writer, def)
    end using
      ' read in the stored


相关文档:

SQl Xml和C# Xml数据的一点操作总结

SQl Xml和C# Xml数据的一点操作总结
在此申明Xml是InfoSet数据不是字符串,所以在此强烈反对用string拼接xml。数据库可以存放xml类型数据,那么该数据的具体操作又如何了。
1.首先建立一张含有xml数据类型的表
CREATE TABLE [dbo].[TestXml](
 [ID] [bigint] IDENTITY(1,1) NOT NULL,
 [Message] [xml] NULL ......

关于xml删除节点的问题

前面文章中提到 xml节点的删除
“删除 <book genre="fantasy" ISBN="2-3631-4">节点的genre属性,删除 <book genre="update陶维佳" ISBN="2-3631-4">节点。”
代码: 
 XmlNodeList xnl=xmlDoc.SelectSingleNode("bookstore").ChildNodes; 
  foreach(XmlNode&nbs ......

Asp.Net XML操作基类

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Text; ......

VB.NET2005读取XML数据

通过调用CreateDataSetfromXml取得XML数据
Imports System.Xml
Public Const FILE_CONFIG = "MZZ.xml"
Public Const PATH_CONFIG = "\XML\"
Dim dstXML As DataSet
Dim tblXML_DB As DataTable
Dim dtCod As New DataTable
Dim strSQL As String = ""

clsPublic ......

Loading XML data using ActionScript 3.0

Loading XML data using ActionScript 3.0
By Blue_Chi | Flash CS3 | ActionScript 3.0 | Beginner
Using XML is one of the best ways for structuring external content in a logical format that is easy to understand, process, and update. This tutorial will teach you the basics on how to load and process X ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号