Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

magento ¿ª·¢ ÁíÒ»ÖÖ·½Ê½ÓÃxmlÀ´²¼¾Ö

ÊÇ·ñÑá¾ëÁËÓÃxmlÎļþÀ´×öMagentoµÄÒ³Ãæ²¼¾Ö£¬ÊǵϰÀ´ÊÔÊÔÏÂÃæÕâÖÖ·½Ê½£¬°Ñ²¼¾Ö´úÂëдµ½controller ÀïÃæ
public function mycoolAction()
{
/* ... Some code ...*/
$update = $this->getLayout()->getUpdate();
/* ... Some code ...*/
$this->addActionLayoutHandles();
/* ... Some code ...*/
......

¹ØÓÚ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; ......

microsoft.xmldom(Ò») xmlÎĵµ±éÀújs

xml:
<?xml version="1.0" encoding="utf-8" ?>
<library>
 <name>Ê×¶¼Í¼Êé¹Ý</name>
 <address>³¯ÑôÇø»ªÍþÇÅÄÏ</address>
 <books>
  <book>
   <id>0000</id>
  </book>
  < ......

¶àÖÖXML½âÎö·½·¨

±¾ÎĽéÉÜÁ˸÷ÖÖ½âÎö·½·¨£¬×ÅÖØ·ÖÎöÁ˸÷×ÔµÄÓÅȱµã:
½âÎöµÄÖØÒªÐÔ
¡¡¡¡½âÎöÎªÊ²Ã´ÖØÒª?ÒòΪËùÓÐ XML ´¦Àí¶¼´Ó½âÎö¿ªÊ¼¡£ÎÞÂÛʹÓø߲ã±à³ÌÓïÑÔ(Èç XSLT)»¹ÊǵͲã Java ±à³Ì£¬µÚÒ»²½¶¼ÊÇÒª¶ÁÈë XML Îļþ£¬½âÂë½á¹¹ºÍ¼ìË÷ÐÅÏ¢µÈµÈ£¬Õâ¾ÍÊǽâÎö¡£
¡¡¡¡½âÎöÎĵµÊ±ÃæÁٵĵÚÒ»¸öÑ¡ÔñÊDzÉÓÃÏֳɵĽâÎö¿â(»ù±¾ÉÏÿÖÖ±à³ÌÓïÑÔ¶¼Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ