解决方案 »
- 如何不用钩子判断回车键是否被按下呢~?
- 关于拼音码中的数字与英文
- 调用copymemory()函数时,若传递的第二个参数是string类型,应该怎么办?
- [fatal error] :file not found:'aaa.dcu' 遇到这种问题如何解决?
- 关于goto 语句
- 请问如何用流把TXT或Word文件包存到SQLServer中
- 菜鸟:adotable连接access的一个错误!帮忙啊!
- 请问如何在显示日期型字段时只显示年~急!
- [请各位高手帮忙!!!]要如何才能将在DBGrid中显示出来的内容打印出来???
- 为什么我有WebBroker做的dll,浏览时不是打开界面,而是提示要你下载它
- vcl=mfc,fmx=qt
- 这个是不是xe2的bug
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, StdCtrls, msxmldom, XMLDoc, ExtCtrls;type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
xd1: TXMLDocument;
mm,nn: IXMLNode;
begin
//生成
xd1 := TXMLDocument.Create(application);
xd1.Active := True;
xd1.Encoding := 'utf-8';
xd1.StandAlone := 'yes';
xd1.Version := '1.0';
xd1.Options := [doNodeAutoIndent];
mm := xd1.Node.AddChild('package','http://www.idpf.org/2007/opf');
mm.SetAttributeNS('unique-identifier','','BookId');
mm.SetAttributeNS('version','','2.0'); nn := mm.AddChild('metadata',mm.NamespaceURI);
nn.DeclareNamespace('','http://www.idpf.org/2007/opf');
nn.DeclareNamespace('dc','http://purl.org/dc/elements/1.1/');
nn.DeclareNamespace('opf','http://www.idpf.org/2007/opf');
nn.AttributeNodes.Delete('xmlns',''); xd1.SaveToFile('d:\test1.xml');
xd1.Active := False;
xd1.Destroy;
end;procedure TForm1.Button2Click(Sender: TObject);
var
xd1: TXMLDocument;
i: integer;
mNode,mm: IXMLNode;
begin
//读取
xd1 := TXMLDocument.Create(application);
xd1.FileName := 'd:\test1.xml';
xd1.Active := True;
mNode := xd1.ChildNodes.FindNode('package');
showmessage(mNode.NamespaceURI);
mNode := mNode.ChildNodes.FindNode('metadata');
for i:=0 to mNode.AttributeNodes.Count -1 do
begin
mm := mNode.AttributeNodes.Get(i);
showmessage(mm.LocalName);
end;
showmessage(mNode.FindNamespaceURI('dc'));
showmessage(mNode.FindNamespaceURI('opf'));
xd1.Active := False;
xd1.Destroy;end;end.