DEFINE TEMP-TABLE ttTest
FIELD One AS CHARACTER
FIELD Two AS CHARACTER
FIELD Three AS CHARACTER
.
我希望有两个'两个'有一个属性' name'然后是一个值。
所以它最终会像这样......
<ttTest>
<One>bla</One>
<Two name="somethingLifeChanging">blabla</Two>
<Three>blablabla</Three>
</ttTest>
&#13;
我有什么想法可以实现这个目标吗?
答案 0 :(得分:3)
使用DataSet几乎可以到达那里(如果你不关心元素的顺序):
define temp-table ttTest
field parent as recid xml-node-type "hidden"
field One as char
field Three as char
.
define temp-table ttTestTwo serialize-name "Two"
field parent as recid xml-node-type "hidden"
field name as char xml-node-type "attribute"
field Two as char xml-node-type "text"
.
define dataset ds serialize-hidden
for ttTest,ttTestTwo
data-relation for ttTest,ttTestTwo relation-fields( parent, parent ) nested foreign-key-hidden.
create ttTest.
assign
ttTest.parent = recid(tttest)
ttTest.One = "bla"
ttTest.Three = "blablabla"
.
create ttTestTwo.
assign
ttTestTwo.parent = recid( ttTest )
ttTestTwo.name = "something"
ttTestTwo.Two = "blabla"
.
def var lcc as longchar.
dataset ds:handle:write-xml( "longchar", lcc, true ).
message string(lcc ) view-as alert-box.
然后输出:
---------------------------
Message
---------------------------
<?xml version="1.0"?>
<ttTest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<One>bla</One>
<Three>blablabla</Three>
<Two name="something">blabla</Two>
</ttTest>
---------------------------
OK
---------------------------
答案 1 :(得分:1)
您必须将临时表XML写入X-DOCUMENT并在那里操作XML。