read xml Progress 9.1E Windows XP

Hello,
I try to read the following XML-file, but I can't read the nodes 'EANS' and
'KONDITIONEN' .
Can anyone help me?
The file:
<?xml version="1.0" encoding="utf-8"?>
<datareform>
<kopf
kundennummer="9200"
kundenname="Test Kunde"
version="0.0.7.24" />
<artikels>
<artikel
satzid="2127"
bonbezeichnung="Tagescreme grün"
masszahl="50"
einheit="ml"
mwst="2"
status="2"
hersteller="43"
herstellernr="403"
lose="False"
qobest="True"
kassebest="True"
tarakz="False"
pfandkz="False">
<eans>
<ean
nr="4104490004039" />
</eans>
<konditionen>
<kondition
filiale="0"
vk="17.3900"
normvk="17.3900" />
</konditionen>
</artikel>
</artikels>
</datareform>
The code:
create widget-pool.
define variable hDoc as handle.
define variable hRoot as handle.
define variable hTable as handle.
define variable hField as handle.
def var hwert as handle.
define variable hText as handle.
define variable hTTBuffer as handle.
define variable hTTBufferartikel as handle.
define variable hDBField as handle.
define variable nodepointer as integer.
define variable counter as integer.
define temp-table artikel like kassart.
define temp-table Custt like benutzer.
create x-document hDoc.
create x-noderef hRoot.
create x-noderef hTable.
create x-noderef hField.
create x-noderef hText.

hTTBuffer = buffer Custt:handle.
hTTBufferartikel = buffer artikel:handle.
def var TableName as char.
def var htbl as handle.
DEF VAR logvar AS LOG NO-UNDO.
DEF VAR j AS INT NO-UNDO.
DEF VAR k AS INT NO-UNDO.
DEF VAR txt AS CHAR NO-UNDO.
do with frame {&frame-name}:
hDoc:load("file", filename:screen-value, false).
hDoc:get-document-element(hRoot).
repeat nodepointer = 1 to hRoot:num-children:
logvar = hRoot:get-child(hTable,nodepointer).
IF NOT logvar THEN NEXT.
if hTable:attribute-names <> "" then do:
REPEAT j = 1 TO NUM-ENTRIES(hTable:attribute-names):
txt = ENTRY(j,hTable:attribute-names).
END.
end.
repeat counter = 1 to hTable:num-children:
logvar = hTable:get-child(hField,counter).
if hfield:attribute-names <> "" then do:
REPEAT j = 1 TO NUM-ENTRIES(hfield:attribute-names):
txt = ENTRY(j,hfield:attribute-names).
END.
END.
repeat k = 1 to hfield:num-children:
logvar = hfield:get-child(htext,k).
if htext:attribute-names <> "" then do:
REPEAT j = 1 TO NUM-ENTRIES(htext:attribute-names):
txt = ENTRY(j,htext:attribute-names).
END.
end.
END.
end.
END.
end.

With kind regards
Matthias Röttgermann
 
Matthias,

I have looked to your xml file and your program. the nodes you cannot read are on another level. I think the next procedure can help you to solve your problem.

Code:
DEFINE VARIABLE hDocument           AS HANDLE       NO-UNDO.
DEFINE VARIABLE hNodeRef            AS HANDLE       NO-UNDO.
DEFINE VARIABLE iIndex              AS INTEGER      NO-UNDO.
CREATE WIDGET-POOL.
CREATE X-DOCUMENT hDocument.
hDocument:LOAD("file","c:\temp\test.xml",FALSE).
CREATE X-NODEREF hNoderef.
hDocument:GET-DOCUMENT-ELEMENT(hNoderef).

IF hNodeRef:SUBTYPE = "ELEMENT" THEN RUN getElements(hNoderef).
DELETE WIDGET-POOL.
PROCEDURE getElements:
    DEFINE INPUT PARAMETER hNodeRef         AS HANDLE   NO-UNDO.
    DEFINE VARIABLE hChild                  AS HANDLE   NO-UNDO.
    DEFINE VARIABLE iCnt                    AS INTEGER  NO-UNDO.
    CREATE X-NODEREF hChild.
    DO iCnt = 1 TO hNodeRef:NUM-CHILDREN:
        hNoderef:GET-CHILD(hChild,iCnt).
        IF hChild:SUBTYPE = "ELEMENT" THEN DO: 
            MESSAGE hChild:NAME
                VIEW-AS ALERT-BOX INFO BUTTONS OK.
            IF hChild:ATTRIBUTE-NAMES <> "" THEN
                RUN GetAttributes (hChild).  
            RUN getElements (hChild).
        END.
    END.
    DELETE OBJECT hChild.
END PROCEDURE.
PROCEDURE GETATTRIBUTES:
    DEFINE INPUT PARAMETER hChild           AS HANDLE   NO-UNDO.
    DEFINE VARIABLE iCnt                    AS INTEGER  NO-UNDO.
    DO iCnt = 1 TO NUM-ENTRIES(hChild:ATTRIBUTE-NAMES):
        MESSAGE ENTRY(iCnt,hChild:ATTRIBUTE-NAMES)
            VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END.
END PROCEDURE.

greetings,
Ruud
 
Hello Ruud,
thank's you very much!
I did not know that I can work with the subtype 'Element'.
Now I get all the nodes.
With kind regards
Matthias
 
Hi , I have de samme problem so i take the example and now I know the name of the elements, but ho can y get the conteins of this elements.

Can you help.

this is my XML file

<?xml version="1.0" encoding="ISO-8859-1"?>
<CATALOG>
<ITEM>
<USERNAME>test</USERNAME>
<PASSWORD>test1</PASSWORD>
<ITEMNO>BB55667Y</ITEMNO>
</ITEM>
</CATALOG>
 
Back
Top