• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Question Xml Dom (10.2b)

#1
Hello to All,

maybe help me regarding XML DOM (10.2b).
I this example I can read attribute like "-<person id="Big.Boss">" but I don't understand how I can read this kind of attribute <family>Worker</family>. Could you pls explain me?

Thanks in advance.

JCA
Code:
DEFINE VARIABLE hDoc AS HANDLE.
DEFINE VARIABLE hRoot AS HANDLE.
DEFINE VARIABLE good AS LOGICAL.

CREATE X-DOCUMENT hDoc.
CREATE X-NODEREF hRoot.

hDoc:LOAD("file","personal.xml",TRUE).
hDoc:GET-DOCUMENT-ELEMENT(hRoot).

RUN GetChildren(hRoot, 1).
DELETE OBJECT hDoc.
DELETE OBJECT hRoot.

PROCEDURE GetChildren:
DEFINE INPUT PARAMETER hParent AS HANDLE.
DEFINE INPUT PARAMETER level AS INTEGER.
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE hNoderef AS HANDLE.

CREATE X-NODEREF hNoderef.

REPEAT i = 1 TO hParent:NUM-CHILDREN:
    good = hParent:GET-CHILD(hNoderef,i).
    IF NOT good THEN LEAVE.
    IF hNoderef:SUBTYPE <> "element" THEN NEXT.
    IF hNoderef:NAME = "link" THEN
        MESSAGE "getattr id gives" hNoderef:GET-ATTRIBUTE("manager")
          hNoderef:ATTRIBUTE-NAMES.
    RUN GetChildren(hNoderef, (level + 1)).
END.

DELETE OBJECT hNoderef.
END PROCEDURE.
HTML:
<?xml version="1.0"?>

<!DOCTYPE personnel SYSTEM "personal.dtd">

<!-- Revision: 63 1.7.1.1 samples/data/personal.xml, xml4c2Docs, xml4c2_2_x -->

-<personnel>


-<person id="Big.Boss">


-<name>

<family>Boss</family>

<given>Big</given>

</name>

<email>chief@foo.com</email>

<link subordinates="one.worker two.worker three.worker four.worker five.worker"/>

</person>


-<person id="one.worker">


-<name>

<family>Worker</family>

<given>One</given>

</name>

<email>one@foo.com</email>

<link manager="Big.Boss"/>

</person>


-<person id="two.worker">


-<name>

<family>Worker</family>

<given>Two</given>

</name>

<email>two@foo.com</email>

<link manager="Big.Boss"/>

</person>


-<person id="three.worker">


-<name>

<family>Worker</family>

<given>Three</given>

</name>

<email>three@foo.com</email>

<link manager="Big.Boss"/>

</person>


-<person id="four.worker">


-<name>

<family>Worker</family>

<given>Four</given>

</name>

<email>four@foo.com</email>

<link manager="Big.Boss"/>

</person>


-<person id="five.worker">


-<name>

<family>Worker</family>

<given>Five</given>

</name>

<email>five@foo.com</email>

<link manager="Big.Boss"/>

</person>

</personnel>
 
Last edited by a moderator: