2013-02-14 69 views
0

我收到了一個'xml'文件,雖然它看起來不像XML。我知道它是從Microsoft Access或SQLServer導出的。該文件看起來是這樣的:從SQLServer解析XML文件

>>> contents[:1000] 
'\xef\xbb\xbf<?xml version="1.0"?><Report xmlns="Ascent_x0_Metadata_x0020_Report_x0020__x002ted" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="Ascent_x0020_Me0_Repo29__x0020_updated http://reportserver? 
%2fAsata+Report+(by+Title+Letter)+updated&amp;rs%3aFormat=XML&amp;rc%3aSchema=True" 
Name="Ascent Report (by Title Letter) updated"> 
    <table1> 
     <Detail_Collection> 
      <Detail ISOCountry="AR" TitleSort="A Very Brady Sequel" 
       ReleaseYear="1996" TitleKind="N/A" TitleType="N/A"... 

此外,我甚至無法在TextMate打開這個文件 - 每次我嘗試它的時候崩潰的程序。

+0

\ xef \ xbb \ xbf是我不知道這是否有幫助,但就是這樣。它對我來說看起來像XML。在第一對字節中只有一些垃圾? – Dave 2013-02-14 06:37:26

回答

2

第一個十六進制字符是UTF-8字節順序標記(http://en.wikipedia.org/wiki/Byte_order_mark0xEF,0xBB,0xBF)。

這只是表示您收到的內容編碼爲UTF-8,您應該通過設置您用來閱讀內容的編碼來對待它。 XML文件的其餘部分看起來沒問題。

Textmate應該用UTF-8做得很好,但也許文件太大了。