私は Delphi 7 (個人用) で開発しています。以前は XML の処理に JvSimpleXML を使用していましたが、WideStrings を処理していないようです (または処理しますか?!)。私のプロジェクト全体では、インターフェイスに TntWide... と SpTBXLib を使用しているため、Unicode をうまく処理できます。いくつかの設定をファイルに保存する必要があります。アイデア?
前もってありがとうミハル
Delphiから dll をインポートするMSXML 6 (Microsoft XML Core Services)の最新バージョンを使用できます。
生成されたコードの例を次に示します
// *********************************************************************//
// 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;
編集
XMLDoc.pas にあるオブジェクト TXMLDocument (delphi 7 用) は、バージョン 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;
マイクロソフトのサイトから:
MSXML4 は、機能を追加してパフォーマンスを向上させるために導入されましたが、MSXML6 に取って代わられました。MSXML4 を使用しているお客様は、スケジュールの制約が許し次第、MSXML6 への移行を検討する必要があります。
さよなら
OmniXMLをチェックアウトします。msxml の代わりに使い始めました。また、非常に滑らかな「 FluentXMLBuilder 」も提供します。
Delphi に付属の TXMLDocument は、WideStrings/Unicode を適切に処理します。デフォルトでは、ここに記載されている MSXML ライブラリを使用します。DOM ライクな API です。例については、 http://delphi.about.com/library/weekly/aa101904a.htmを参照してください。
手頃な価格ですが無料ではありません。Storage Library @ http://www.deepsoftware.com/rsllib/は、XML、INI、レジストリなどとして保存します。
XSD スキーマまたは XSL を使用した変換を確認する必要がある場合は、DIXmlを調べてください。