2016-06-15 20 views
1
DEFINE TEMP-TABLE ttTest 
FIELD One AS CHARACTER 
FIELD Two AS CHARACTER 
FIELD Three AS CHARACTER 
. 

我想要字段'Two'具有屬性'名稱',然後是值。如何將xml屬性添加到正在進行的臨時表字段中

所以它結束了像這樣...

<ttTest> 
 
     <One>bla</One> 
 
     <Two name="somethingLifeChanging">blabla</Two> 
 
     <Three>blablabla</Three> 
 
    </ttTest>

任何想法如何,我可以去實現這一目標?

回答

3

使用數據集,你幾乎可以到達那裏(如果你不關心元素的順序):

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 
--------------------------- 
+0

工作就像一個魅力。謝謝! – Ivan

1

您必須將臨時表XML寫入X-DOCUMENT並在其中操作XML。

+0

我怕的就是這個。非常感謝你。 – Ivan

相關問題