xml import

BeliasBelias Member Posts: 2,998
edited 2009-10-29 in Navision Attain
NAV310, fdb
Hi everyone, this is my first experience with xml, so, promise you'll be kind :)

This is a "chop" of the XML i want to import
- <gnc:transaction version="2.0.0">
<trn:id type="guid">4cc8f2d05a988f5f8a9d4d2c304ebadc</trn:id>
- <trn:currency>
<cmdty:space>ISO4217</cmdty:space>
<cmdty:id>INR</cmdty:id>
</trn:currency>
- <trn:date-posted>
<ts:date>2009-05-20 00:00:00 +0200</ts:date>
</trn:date-posted>
- <trn:date-entered>
<ts:date>2009-05-19 15:21:30 +0200</ts:date>
</trn:date-entered>
<trn:description>project manager salary</trn:description>
- <trn:splits>
- <trn:split>
<split:id type="guid">9630c8ffb8745d6572b0954c5237b724</split:id>
<split:reconciled-state>y</split:reconciled-state>
- <split:reconcile-date>
<ts:date>2009-05-20 23:59:59 +0200</ts:date>
</split:reconcile-date>
<split:value>2000000/100</split:value>
<split:quantity>29837/100</split:quantity>
<split:account type="guid">4cb93d4fbb0656d2a4225dbaaa161e94</split:account>
</trn:split>
- <trn:split>
<split:id type="guid">7e090b3e8f5d137e96ea26970b345a88</split:id>
<split:reconciled-state>y</split:reconciled-state>
- <split:reconcile-date>
<ts:date>2009-05-20 23:59:59 +0200</ts:date>
</split:reconcile-date>
<split:value>-2000000/100</split:value>
<split:quantity>-2000000/100</split:quantity>
<split:account type="guid">c7e4296146f70fc2d9ccb02b17f93bf2</split:account>
</trn:split>
</trn:splits>
</gnc:transaction>

I am currently using this code to read the split tag (this is a prototype, a little hardcoded):
TXTNodeName[1] := 'trn:split';
TXTTrnID := 'split:quantity';

FNTGetList(1,TXTNodeName);
TXTNodeText := '';
INTDeepNess := 1;
IF XMLNode[1].hasChildNodes THEN BEGIN
  REPEAT
    //some code
    XMLNode[INTDeepNess] := XMLNodeList[INTDeepNess].nextNode;
  UNTIL ISCLEAR(XMLNode[INTDeepNess]);
END;

FNTGetList(pINTDeepNess : Integer;pTXTNodeName : ARRAY [20] OF Text[250])
XMLNodeList[pINTDeepNess] := XMLDoc.getElementsByTagName(pTXTNodeName[pINTDeepNess]);
XMLNode[pINTDeepNess] := XMLNodeList[pINTDeepNess].item(0);

My problem is that this code reads all the 'split:quantity' of the transaction, while i want to read:
-split:quantity of the first <trn:split>
-do something
-split:quantity of the second <trn:split>

Hope to be clear....it's a bit hard to explain xml...

Indentation of xml screwed up,i'm sorry...

For your entartainment: a customer called me just now, saying
cust: "i'm trying to insert an invoice and it keeps giving me: 'you have to compile buy-from field in sales header..."
me: "did you compile buy-from field in sales header?"
cust: "no"
](*,) ](*,) ](*,) ](*,)
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • SavatageSavatage Member Posts: 7,142
    Xml ports is something we don't use either only thing I can suggest is this sample
    viewtopic.php?f=7&t=2266
  • BeliasBelias Member Posts: 2,998
    Savatage wrote:
    Xml ports is something we don't use either only thing I can suggest is this sample
    viewtopic.php?f=7&t=2266
    already downloaded and cutted into piece to understand it :)
    Thanks to the one who posted it...but my question is not really clear, maybe...i'll try with a more readable example..

    Here's xml
    <aaa>
    ---<bbb>I</bbb>
    ---<ccc>hate</ccc>
    </aaa>
    <aaa>
    ---<bbb>XML</bbb>
    ---<ccc>!</ccc>
    </aaa>

    if i load the nodelist of bbb, i'll get "I" and "XML" nodes.
    but what if i want to read the xml like this:
    <aaa> parent: read bbb and ccc, do something, but i don't want to read the second bbb because it is son of the second aaa!!!how can i do it?and more important..CAN i do it?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.