Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡¾ÇóÖú¡¿python xmlÎļþ¶ÁÈ¡ºÍת»»ÎÊÌâ

#½«GB2312¸ñʽתΪUTF-8¸ñʽ
    f = codecs.open('e:\TestResult.xml', "rb", "gb2312")
    text = f.read().encode("utf-8") 
    f.close
    f = open(options.TestResultFile, "wb") 
    f.write(text) 
    f.close() 

Ìáʾ  File "E:\TOOLS\ICP\ICP-23\cruisecontrol\userData\groups\group01\projects\R12ProductTest\script\pyt
hon_script\StaticResult.py", line 29, in main
    text = f.read().encode("utf-8") 
  File "C:\Python25\lib\codecs.py", line 606, in read
    return self.reader.read(size)
UnicodeDecodeError: 'gb2312' codec can't decode bytes in position 55-56: illegal multibyte sequence

ÊÇf.read()³öÁËÎÊÌ⣬ÒòΪ¡£encode("utf-8")  È¥µôÈÔÈ»ÊǸÃÏÖÏó¡£

²»ÖªµÀÎÒÕâÀï¶ÁÈ¡ÓкÎÎÊÌ⣿

ÕâÊdzÉÊìµÄ²úÆ·´úÂ룬ÒѾ­ÓбðÈËÔÚʹÓ᣶øÇÒÎÒʹÓÃËûÃÇͬÑùµÄÎļþÀ´²Ù×÷£¬ÒÔ¼°Í¬ÑùµÄpython°æ±¾£¨2.5£©Ò²ÊÇÕâÑùµÄÎÊÌ⣬ºÃÆæ¹Ö£¡


¶ÔÁË£¬ÍüÁË open

Python code:

def _openAnything(self, source):
try:
f = urllib.urlopen(source)
data = f.read()


Ïà¹ØÎÊ´ð£º

ÀûÓÃC#±àдtxtת»¯µ½xmlµÄ³ÌÐò

txt ºÍXML ¸ñʽÏàÓ¦
²»½èÖúDataSet
µ¼Èë¶ÁÈ¡TXTÎļþ
È»ºóÖ±½ÓдÈëXML(ͬһÎļþ,²»Í¬Êý¾Ý,µÝÔöÔ­Êý¾ÝûÓб»¸²¸ÇÇé¿öÏÂÔö¼ÓÊý¾Ý.)
½Ì¸öÒªµã»ò×îºÃÊÇÓиö´úÂëÌáʾµÄ
¹ý·ºÃºº °ï¸öæÈö^^
²»»á£¬°ïÂ¥Ö÷ ......

ÈçºÎÌá½»xmlÀàÐÍÊý¾Ý - .NET¼¼Êõ / ASP.NET

Êý¾Ý¿â±íÖÐÓÐÒ»ÁУ¨TranXml£©ÀàÐÍÊÇxml£¬´æ´¢µÄÊÇÀàËÆ
<fathernode>
  <a>aaa
  </a>
  <b>bbb
  </b>
</fathernode>
µÄÐÅÏ¢£¬²¢ÇÒͨ¹ý²éѯ·½· ......

wince³ÌÐòÔõô°ÑXMLÎļþ´«Èëwebservice

ÎÒÔÚ±àдһ¸öwince5.0µÄ³ÌÐò£¬ÏëʵÏÖ°ÑPDAÉϵÄÒ»¸öLIST <STRING>ÀàÐ͵ÄÊý¾ÝÐòÁл¯ÎªXML£¬È»ºóÔÚPCÉϵÄÒ»¸öwebserviceÄõ½Õâ¸öXML£¬×ª»¯ÎªDataset£¬¸üÐÂPCÉϵÄÊý¾Ý¿â£¬ÎÒÏëÎÊÔõô°ÑXML´«¸øwebserviceµÄÄØ£¿
......

ÇëÎÊÈçºÎÈ¡XMLµÄÊôÐÔÖµ - .NET¼¼Êõ / C#

ÎÒÓÐÒ»¸öXML.ÏëÈ¡
<Portfolio _Name="XXXX" _Id="AUD" >
ÖеÄÊôÐÔ_IdµÄÖµ.µ«ÊÇÓÃÏÂÃæµÄÓï¾äºÃÏó²»ÐÐ.
 XmlNode CId = xdoc_Msg.SelectSingleNode("/Portfolio");
&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ