我正在使用Delphi 7(個人版)進行開發。我曾經使用JvSimpleXML進行XML處理,但它似乎並沒有處理WideStrings(或者它呢?!)。我的整個項目使用TntWide ... & SpTBXLib接口,所以它處理Unicode非常好,我現在需要將一些設置存儲在文件中...所以我正在尋找解決方案或(免費)替換JvSimpleXML ...任何想法?Delphi 7,支持Unicode的XML處理
在此先感謝 米哈爾
我正在使用Delphi 7(個人版)進行開發。我曾經使用JvSimpleXML進行XML處理,但它似乎並沒有處理WideStrings(或者它呢?!)。我的整個項目使用TntWide ... & SpTBXLib接口,所以它處理Unicode非常好,我現在需要將一些設置存儲在文件中...所以我正在尋找解決方案或(免費)替換JvSimpleXML ...任何想法?Delphi 7,支持Unicode的XML處理
在此先感謝 米哈爾
結帳OmniXML。我已經開始使用它而不是msxml。它也給你'非常漂亮的'FluentXMLBuilder'。
負擔得起的,但不是免費的,存儲庫@http://www.deepsoftware.com/rsllib/將保存爲XML,INI,Regitry等
可以使用的部份MSXML 6(微軟XML Core Services中的最新版本)從delphi導入dll。
http://i27.tinypic.com/2gw95hu.jpg
這裏是生成的代碼的一個示例
// *********************************************************************//
// Interface: IXMLDOMDocument
// Flags: (4560) Hidden Dual NonExtensible OleAutomation Dispatchable
// GUID: {2933BF81-7B36-11D2-B20E-00C04F983E60}
// *********************************************************************//
IXMLDOMDocument = interface(IXMLDOMNode)
['{2933BF81-7B36-11D2-B20E-00C04F983E60}']
function Get_doctype: IXMLDOMDocumentType; safecall;
function Get_implementation_: IXMLDOMImplementation; safecall;
function Get_documentElement: IXMLDOMElement; safecall;
procedure _Set_documentElement(const DOMElement: IXMLDOMElement); safecall;
function createElement(const tagName: WideString): IXMLDOMElement; safecall;
function createDocumentFragment: IXMLDOMDocumentFragment; safecall;
function createTextNode(const data: WideString): IXMLDOMText; safecall;
function createComment(const data: WideString): IXMLDOMComment; safecall;
function createCDATASection(const data: WideString): IXMLDOMCDATASection; safecall;
function createProcessingInstruction(const target: WideString; const data: WideString): IXMLDOMProcessingInstruction; safecall;
function createAttribute(const name: WideString): IXMLDOMAttribute; safecall;
function createEntityReference(const name: WideString): IXMLDOMEntityReference; safecall;
function getElementsByTagName(const tagName: WideString): IXMLDOMNodeList; safecall;
function createNode(type_: OleVariant; const name: WideString; const namespaceURI: WideString): IXMLDOMNode; safecall;
function nodeFromID(const idString: WideString): IXMLDOMNode; safecall;
function load(xmlSource: OleVariant): WordBool; safecall;
function Get_readyState: Integer; safecall;
function Get_parseError: IXMLDOMParseError; safecall;
function Get_url: WideString; safecall;
function Get_async: WordBool; safecall;
procedure Set_async(isAsync: WordBool); safecall;
procedure abort; safecall;
function loadXML(const bstrXML: WideString): WordBool; safecall;
procedure save(destination: OleVariant); safecall;
function Get_validateOnParse: WordBool; safecall;
procedure Set_validateOnParse(isValidating: WordBool); safecall;
function Get_resolveExternals: WordBool; safecall;
procedure Set_resolveExternals(isResolving: WordBool); safecall;
function Get_preserveWhiteSpace: WordBool; safecall;
procedure Set_preserveWhiteSpace(isPreserving: WordBool); safecall;
procedure Set_onreadystatechange(Param1: OleVariant); safecall;
procedure Set_ondataavailable(Param1: OleVariant); safecall;
procedure Set_ontransformnode(Param1: OleVariant); safecall;
property doctype: IXMLDOMDocumentType read Get_doctype;
property implementation_: IXMLDOMImplementation read Get_implementation_;
property documentElement: IXMLDOMElement read Get_documentElement write _Set_documentElement;
property readyState: Integer read Get_readyState;
property parseError: IXMLDOMParseError read Get_parseError;
property url: WideString read Get_url;
property async: WordBool read Get_async write Set_async;
property validateOnParse: WordBool read Get_validateOnParse write Set_validateOnParse;
property resolveExternals: WordBool read Get_resolveExternals write Set_resolveExternals;
property preserveWhiteSpace: WordBool read Get_preserveWhiteSpace write Set_preserveWhiteSpace;
property onreadystatechange: OleVariant write Set_onreadystatechange;
property ondataavailable: OleVariant write Set_ondataavailable;
property ontransformnode: OleVariant write Set_ontransformnode;
end;
EDIT
目的TXMLDocument的(爲Delphi 7)位於XMLDoc.pas是版本MSXML的包裝4點以下。
const
{ GUID's from MSXML2_TLB.pas }
CLASS_DOMDocument26: TGUID = '{F5078F1B-C551-11D3-89B9-0000F81FE221}';
CLASS_DOMDocument30: TGUID = '{F5078F32-C551-11D3-89B9-0000F81FE221}';
CLASS_DOMDocument40: TGUID = '{88D969C0-F192-11D4-A65F-0040963251E5}';
function CreateDOMDocument: IXMLDOMDocument;
begin
Result := TryObjectCreate([CLASS_DOMDocument40, CLASS_DOMDocument30,
CLASS_DOMDocument26, msxml.CLASS_DOMDocument]) as IXMLDOMDocument;
if not Assigned(Result) then
raise DOMException.Create(SMSDOMNotInstalled);
end;
從Microsoft網站:
MSXML4引入添加功能 和提高性能,但一直 通過MSXML6取代。在日程安排約束 允許的情況下, MSXML4上的客戶應該查看遷移到 MSXML6。
再見
附帶德爾福TXMLDocument的處理WideStrings/Unicode的就好了。默認情況下,它使用這裏提到的MSXML庫。它是一個類似於API的DOM。一個例子見http://delphi.about.com/library/weekly/aa101904a.htm。
如果您需要檢查XSD架構或使用XSL進行轉換,則應該檢出DIXml。
謝謝,這是我的選擇:) – migajek 2009-09-14 16:23:00