1. 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)

Discussion in 'Development' started by gasomma, May 19, 2017 at 8:47 AM.

  1. gasomma

    gasomma Member

    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 (progress):
    1.  
    2. DEFINE VARIABLE hDoc AS HANDLE.
    3. DEFINE VARIABLE hRoot AS HANDLE.
    4. DEFINE VARIABLE good AS LOGICAL.
    5.  
    6. CREATE X-DOCUMENT hDoc.
    7. CREATE X-NODEREF hRoot.
    8.  
    9. hDoc:LOAD("file","personal.xml",TRUE).
    10. hDoc:GET-DOCUMENT-ELEMENT(hRoot).
    11.  
    12. RUN GetChildren(hRoot, 1).
    13. DELETE OBJECT hDoc.
    14. DELETE OBJECT hRoot.
    15.  
    16. PROCEDURE GetChildren:
    17. DEFINE INPUT PARAMETER hParent AS HANDLE.
    18. DEFINE INPUT PARAMETER level AS INTEGER.
    19. DEFINE VARIABLE i AS INTEGER.
    20. DEFINE VARIABLE hNoderef AS HANDLE.
    21.  
    22. CREATE X-NODEREF hNoderef.
    23.  
    24. REPEAT i = 1 TO hParent:NUM-CHILDREN:
    25.     good = hParent:GET-CHILD(hNoderef,i).
    26.     IF NOT good THEN LEAVE.
    27.     IF hNoderef:SUBTYPE <> "element" THEN NEXT.
    28.     IF hNoderef:NAME = "link" THEN
    29.         MESSAGE "getattr id gives" hNoderef:GET-ATTRIBUTE("manager")
    30.           hNoderef:ATTRIBUTE-NAMES.
    31.     RUN GetChildren(hNoderef, (level + 1)).
    32. END.
    33.  
    34. DELETE OBJECT hNoderef.
    35. END PROCEDURE.
    36.  
    HTML:
    1. <?xml version="1.0"?>
    2.  
    3. <!DOCTYPE personnel SYSTEM "personal.dtd">
    4.  
    5. <!-- Revision: 63 1.7.1.1 samples/data/personal.xml, xml4c2Docs, xml4c2_2_x -->
    6.  
    7. -<personnel>
    8.  
    9.  
    10. -<person id="Big.Boss">
    11.  
    12.  
    13. -<name>
    14.  
    15. <family>Boss</family>
    16.  
    17. <given>Big</given>
    18.  
    19. </name>
    20.  
    21. <email>chief@foo.com</email>
    22.  
    23. <link subordinates="one.worker two.worker three.worker four.worker five.worker"/>
    24.  
    25. </person>
    26.  
    27.  
    28. -<person id="one.worker">
    29.  
    30.  
    31. -<name>
    32.  
    33. <family>Worker</family>
    34.  
    35. <given>One</given>
    36.  
    37. </name>
    38.  
    39. <email>one@foo.com</email>
    40.  
    41. <link manager="Big.Boss"/>
    42.  
    43. </person>
    44.  
    45.  
    46. -<person id="two.worker">
    47.  
    48.  
    49. -<name>
    50.  
    51. <family>Worker</family>
    52.  
    53. <given>Two</given>
    54.  
    55. </name>
    56.  
    57. <email>two@foo.com</email>
    58.  
    59. <link manager="Big.Boss"/>
    60.  
    61. </person>
    62.  
    63.  
    64. -<person id="three.worker">
    65.  
    66.  
    67. -<name>
    68.  
    69. <family>Worker</family>
    70.  
    71. <given>Three</given>
    72.  
    73. </name>
    74.  
    75. <email>three@foo.com</email>
    76.  
    77. <link manager="Big.Boss"/>
    78.  
    79. </person>
    80.  
    81.  
    82. -<person id="four.worker">
    83.  
    84.  
    85. -<name>
    86.  
    87. <family>Worker</family>
    88.  
    89. <given>Four</given>
    90.  
    91. </name>
    92.  
    93. <email>four@foo.com</email>
    94.  
    95. <link manager="Big.Boss"/>
    96.  
    97. </person>
    98.  
    99.  
    100. -<person id="five.worker">
    101.  
    102.  
    103. -<name>
    104.  
    105. <family>Worker</family>
    106.  
    107. <given>Five</given>
    108.  
    109. </name>
    110.  
    111. <email>five@foo.com</email>
    112.  
    113. <link manager="Big.Boss"/>
    114.  
    115. </person>
    116.  
    117. </personnel>
     
    Last edited by a moderator: May 19, 2017 at 10:53 AM
  2.  
  3. Stefan

    Stefan Active Member

    The content of an element is a child of the element with subtype "text".

    ABL Dojo
     
  4. gasomma

    gasomma Member

    Many thanks Stefan.

    JCA
     

Share This Page