请讲得详细一点或是提供有关资料,一定高分送上!
解决方案 »
- 请问XLSReadWrite怎么实现对已有的excel xls表格进行指定单元的读取并赋值到string变量上
- 这么热的天还穿5条裤衩,散个分。。。
- 用idftpserver做个ftp,如何获取连接用户的信息
- 在RichEdit中插了一些图标,现在想将这些图标转变成文字,有什么办法?
- 主菜单项的背景颜色怎么改变?
- 请问哪里有 installshield express for delphi 下载!!!
- 求《Delphi下深入Windows核心编程》电子版及源码
- DELPHI初学者有什么好书推荐吗?
- 同志们看看,如何对日期进行运算。
- 求教关于TreeView控件和数据表关联的问题。
- 连接数据库是odbc好还是ADO好啊?他们在用途上的区别是?
- 怎样取得硬盘的序列号?
The TXMLTransform component transforms an XML document into a data packet according to the mapping in a transformation file.Note: You can also use TXMLTransform to convert a data packet that appears in XML format into an arbitrary XML document.Specifying the source XML documentThere are three ways to specify the source XML document:If the source document is a .xml file on disk, you can use the SourceXmlFile property.
If the source document is an in-memory string of XML, you can use the SourceXml property.
If you have an IDOMDocument interface for the source document, you can use the SourceXmlDocument property.TXMLTransform checks these properties in the order listed above. That is, it first checks for a file name in the SourceXmlFile property. Only if
SourceXmlFile is an empty string does it check the SourceXml property. Only if SourceXml is an empty string does it then check the SourceXmlDocument property.Specifying the transformationThere are two ways to specify the transformation that converts the XML document into a data packet:Set the TransformationFile property to indicate a transformation file that was created using xmlmapper.exe.
Set the TransformationDocument property if you have an IDOMDocument interface for the transformation.TXMLTransform checks these properties in the order listed above. That is, it first checks for a file name in the TransformationFile property. Only if TransformationFile is an empty string does it check the TransformationDocument property.Obtaining the resulting data packetTo cause TXMLTranform to perform its transformation and generate a data packet, you need only read the Data property. For example, the following code uses an XML document and transformation file to generate a data packet, which is then assigned to a client dataset:XMLTransform1.SourceXMLFile := 'CustomerDocument.xml';XMLTransform1.TransformationFile := 'CustXMLToCustTable.xtr';
ClientDataSet1.XMLData := XMLTransform1.Data;Converting user-defined nodesWhen you define a transformation using xmlmapper.exe, you can specify that some of the nodes in the XML document are 搖ser-defined? User-defined nodes are nodes for which you want to provide the transformation in code rather than relying on a straightforward node-value-to-field-value translation.
You can provide the code to translate user-defined nodes using the OnTranslate event. OnTranslate is called every time the TXMLTransform component encounters a user-defined node in the XML document. In the OnTranslate event handler, you can read the source document and specify the resulting value for the field in the data packet. For example, the following OnTranslate event handler converts a node in the XML document with the following form <FullName> <Title> </Title>
<FirstName> </FirstName>
<LastName> </LastName>
</FullName>into a single field value:procedure TForm1.XMLTransform1Translate(Sender: TObject; Id: String; SrcNode: IDOMNode; var Value: String; DestNode: IDOMNode);
var
CurNode: IDOMNode;
begin
if Id = 'FullName' then
begin
Value = '';
if SrcNode.hasChildNodes then
begin
CurNode := SrcNode.firstChild;
Value := Value + CurNode.nodeValue;
while CurNode <> SrcNode.lastChild do
begin
CurNode := CurNode.nextSibling;
Value := Value + ' '; Value := Value + CurNode.nodeValue;
end;
end;
end;
end;