Recently, other project teams encountered a small problem of exporting XML data, because I was familiar with XML operations before, and naturally found my help ending. In fact, Delphi is very convenient to operate XML. The problem is that their xml header must be available! For example, the following XMLCode:
<? XML version = "1.0" encoding = "gb2312" ?>
<! Doctype math system "http://www.w3.org/Math/DTD/mathml1/mathml.dtd" >
< Root >
< Test >
< Add Key = "-1" Filename = "Ofile" />
</ Test >
</ Root >
For the good operations in C #, Delphi has relatively few codes and no results can be found on Google. So I checked Delphi's nativexml. Pas.Source codeWe found that there is a definition of xedoctype, which is exactly what we are looking. Haha ..
The Delphi code for defining XML doctype is as follows:
Uses nativexml
Procedure Tform1.button1click (Sender: tobject );
VaR
XML: tnativexml;
N_bs: txmlnode;
Begin
XML: = Tnativexml. createname ( ' Root ' );
XML. encodingstring: = ' Gb2312 ' ;
XML. xmlformat: = Xfreadable;
// Normal XML section
N_bs: = XML. Root. nodenew ( ' Test ' );
N_bs: = N_bs.nodenew ( ' Add ' );
N_bs.writeattributestring ( ' Key ' , ' -1 ' );
N_bs.writeattributestring ( ' Filename ' , ' Ofile ' );
//Add<! Doctype?>Part
N_bs:=Txmlnode. createtype (XML, xedoctype );
N_bs.valuedirect:= 'Math System "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"';
XML. rootnodelist. nodeinsert (1, N_bs );
XML. savetofile ('1. xml ');
End;
In this way, the above XML file is output.