3
我需要從我的數據庫中獲取數據來創建單獨的xml文件。我已經完成了大部分工作,但我不知道如何從XML字段獲取數據並將其轉移到我創建的XMLDocument中。當我嘗試以文本的形式進行操作時,它無法正常工作。如何從SQL Server 2005中獲取XML數據並將其作爲節點插入到TXMLDocument中?
這裏是我到目前爲止的代碼:
XMLDoc.Active := true;
aNode := XMLDoc.AddChild('item');
aNode.SetAttribute('id','Drug');
bNode := aNode.AddChild('item');
bNode.SetAttribute('id','LDPId');
bNode.Text := IntToStr(vwFirstLifeLabelId.Value); // This works fine.
bNode := aNode.AddChild('item');
bNode.SetAttribute('id','Indications and Usage');
bNode.Text := vwFirstLifeIndicationsandUsage.AsString; // This doesn't work!
我得到的XML是:
<item id="Drug">
<item id="LDPId">38696</item>
<item id="Warnings and Precautions">?<component xmlns="urn:hl7-org:v3"><section ID="Section_5"><id root="2e0bdeb7-2254-4217-b6b6-523848d65112"/> </section></component></item>
</item>
相反的:
<item id="Drug">
<item id="LDPId">38696</item>
<item id="Warnings and Precautions">
<component xmlns="urn:hl7-org:v3">
<section ID="Section_5">
<id root="2e0bdeb7-2254-4217-b6b6-523848d65112"/>
</section>
</component>
</item>
</item>
我想我有兩個問題:1)我如何從xmlfield獲取XML而不是XML文檔,以及2)如何在「警告和注意事項」節點下插入一段XML作爲子項?
感謝任何人都可以幫助我!
特里