Skip to main content

[archive] Trying to Get the Parent from an XML file

  • September 10, 2007
  • 23 replies
  • 0 views

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




23 replies

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




If your whole XML file is encompassed inside the EmailInfo element then that is the element you are located on when you parse the file. Being the document-root, it has no parent - only children.

Use XML-GET-DATA to obtain the EmailInfo element, not XML-GET-PARENT.

Have you got the sample XML program working that posted for you earlier? This really helped me get my head around C$XML.

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




If your whole XML file is encompassed inside the EmailInfo element then that is the element you are located on when you parse the file. Being the document-root, it has no parent - only children.

Use XML-GET-DATA to obtain the EmailInfo element, not XML-GET-PARENT.

Have you got the sample XML program working that posted for you earlier? This really helped me get my head around C$XML.

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Thanks, Ian.

You helped me figure out the FilePath issue I was having before.
But now since I learned that the XML file that I will be parsing could contain multiple "parents", that is why I need to get the parent. I need to know the "parent" because processing will be different for each parent in the XML file.

I could have a XML file like this


blah, blah
blah, blah



blah, blah,
blah, blah


So I need to get the parent and process for the email information, and then I need to get parent and process for the contact information.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Thanks, Ian.

You helped me figure out the FilePath issue I was having before.
But now since I learned that the XML file that I will be parsing could contain multiple "parents", that is why I need to get the parent. I need to know the "parent" because processing will be different for each parent in the XML file.

I could have a XML file like this


blah, blah
blah, blah



blah, blah,
blah, blah


So I need to get the parent and process for the email information, and then I need to get parent and process for the contact information.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Thanks, Ian.

You helped me figure out the FilePath issue I was having before.
But now since I learned that the XML file that I will be parsing could contain multiple "parents", that is why I need to get the parent. I need to know the "parent" because processing will be different for each parent in the XML file.

I could have a XML file like this


blah, blah
blah, blah



blah, blah,
blah, blah


So I need to get the parent and process for the email information, and then I need to get parent and process for the contact information.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




In the previous post, the , , , are all indented. Not sure why when I post the message, it does not leave the indents.

Ian, I just looked at the Example you posted, again, and I doing like you have, but I am not getting "EmailInfo" to come back.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




In the previous post, the , , , are all indented. Not sure why when I post the message, it does not leave the indents.

Ian, I just looked at the Example you posted, again, and I doing like you have, but I am not getting "EmailInfo" to come back.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




OK, I was able to get "EmailInfo" from the XML file by only using the XML-GET-DATA, right after the XML-PARSE-FILE

But, I still have the issue of being able to get the next parent .
Not sure how I would do that????

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




OK, I was able to get "EmailInfo" from the XML file by only using the XML-GET-DATA, right after the XML-PARSE-FILE

But, I still have the issue of being able to get the next parent .
Not sure how I would do that????

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




A well-formed XML file has only one document root, which will be the first element returned when you parse the file. So I'm thinking your file should look like this:-

 
    blah, blah
    blah, blah
 

 
    blah, blah,
    blah, blah
 
Then the EmailInfo and ContactInfo are all children of your document-root element. Is this how your file really is?

If you're working in Windows, try to open your XML file in a browser to see if your XML file is well-formed or not (there are probably other ways). If you're working in Linux, use xml_parser or xmlwf to check your file. Parsing the sample you provided returns errors using all of these test methods.

In my example above, I would do something like this:-
CALL "C$XML" USING CXML-PARSE-FILE, filename.
MOVE RETURN-CODE    TO  XML-PARSER-HANDLE.
CALL "C$XML" USING CXML-GET-FIRST-CHILD, XML-PARSER-HANDLE.
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(1),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "EmailInfo"
            Perform Email-info
        WHEN "ContactInfo"
            perform Contact-Info
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(1)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1)
end-perform.

Email-info.
**** Similar code - but the handles and subscripts change...
CALL "C$XML" USING CXML-GET-FIRST-CHILD, WS99-XML-ELEMENT-HANDLES(1).
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(2),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "Filepath"
            do stuff
        WHEN "subject"
            do stuff
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(2)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2)
end-perform.


By keeping track of XML handles in an array like this (more like a stack really - and the idea was pinched from Acucorp's example program), you remove the need for moving up-and-down the tree using the PARENT options in C$XML. When you've exhausted all of the XML elements at the subscript-2 level (i.e. return-code is now zero, you go back up to the handle at subscript-1 and get the next sibling at that level - simply by referencing it by the handle you've saved in your array.

I hope I'm helping and not confusing you :)

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




A well-formed XML file has only one document root, which will be the first element returned when you parse the file. So I'm thinking your file should look like this:-

 
    blah, blah
    blah, blah
 

 
    blah, blah,
    blah, blah
 
Then the EmailInfo and ContactInfo are all children of your document-root element. Is this how your file really is?

If you're working in Windows, try to open your XML file in a browser to see if your XML file is well-formed or not (there are probably other ways). If you're working in Linux, use xml_parser or xmlwf to check your file. Parsing the sample you provided returns errors using all of these test methods.

In my example above, I would do something like this:-
CALL "C$XML" USING CXML-PARSE-FILE, filename.
MOVE RETURN-CODE    TO  XML-PARSER-HANDLE.
CALL "C$XML" USING CXML-GET-FIRST-CHILD, XML-PARSER-HANDLE.
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(1),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "EmailInfo"
            Perform Email-info
        WHEN "ContactInfo"
            perform Contact-Info
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(1)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1)
end-perform.

Email-info.
**** Similar code - but the handles and subscripts change...
CALL "C$XML" USING CXML-GET-FIRST-CHILD, WS99-XML-ELEMENT-HANDLES(1).
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(2),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "Filepath"
            do stuff
        WHEN "subject"
            do stuff
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(2)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2)
end-perform.


By keeping track of XML handles in an array like this (more like a stack really - and the idea was pinched from Acucorp's example program), you remove the need for moving up-and-down the tree using the PARENT options in C$XML. When you've exhausted all of the XML elements at the subscript-2 level (i.e. return-code is now zero, you go back up to the handle at subscript-1 and get the next sibling at that level - simply by referencing it by the handle you've saved in your array.

I hope I'm helping and not confusing you :)

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




A well-formed XML file has only one document root, which will be the first element returned when you parse the file. So I'm thinking your file should look like this:-

 
    blah, blah
    blah, blah
 

 
    blah, blah,
    blah, blah
 
Then the EmailInfo and ContactInfo are all children of your document-root element. Is this how your file really is?

If you're working in Windows, try to open your XML file in a browser to see if your XML file is well-formed or not (there are probably other ways). If you're working in Linux, use xml_parser or xmlwf to check your file. Parsing the sample you provided returns errors using all of these test methods.

In my example above, I would do something like this:-
CALL "C$XML" USING CXML-PARSE-FILE, filename.
MOVE RETURN-CODE    TO  XML-PARSER-HANDLE.
CALL "C$XML" USING CXML-GET-FIRST-CHILD, XML-PARSER-HANDLE.
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(1),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "EmailInfo"
            Perform Email-info
        WHEN "ContactInfo"
            perform Contact-Info
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(1)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(1)
end-perform.

Email-info.
**** Similar code - but the handles and subscripts change...
CALL "C$XML" USING CXML-GET-FIRST-CHILD, WS99-XML-ELEMENT-HANDLES(1).
MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2).
perform until return-code = zero
    CALL "C$XML" using cxml-get-data,
                    WS99-XML-ELEMENT-HANDLES(2),
                    WS99-XML-DATA-NAME,
                    WS99-XML-DATA-ITEM
    EVALUATE WS99-XML-DATA-NAME
        WHEN "Filepath"
            do stuff
        WHEN "subject"
            do stuff
    End-Evaluate
    CALL "C$XML" USING CXML-GET-NEXT-SIBLING,
                          WS99-XML-ELEMENT-HANDLES(2)
    MOVE RETURN-CODE    TO  WS99-XML-ELEMENT-HANDLES(2)
end-perform.


By keeping track of XML handles in an array like this (more like a stack really - and the idea was pinched from Acucorp's example program), you remove the need for moving up-and-down the tree using the PARENT options in C$XML. When you've exhausted all of the XML elements at the subscript-2 level (i.e. return-code is now zero, you go back up to the handle at subscript-1 and get the next sibling at that level - simply by referencing it by the handle you've saved in your array.

I hope I'm helping and not confusing you :)

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Ian,

Thank you for all your knowledge and wisdom.

I wasn't exactly sure what the XML file was going to look like until this week. There is another company that is going the XML file creation part of my project, so I don't have any control over what the XML looks like.

However, the XML file that I am working off, EmailInfo is the document root and Contacts is under it.


-
blah, blah (indented 3 spaces)
blah blah (indented 3 spaces)
- (indented 3 spaces)
- (indented 5 spaces)
blah, blah (indented 7 spaces)
blah, blah (indented 7 spaces)
(indented 5 spaces)
(indented 3 spaces)



So I guess I need to get the children of the child ContactInfo, of the child Contacts?

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Ian,

Thank you for all your knowledge and wisdom.

I wasn't exactly sure what the XML file was going to look like until this week. There is another company that is going the XML file creation part of my project, so I don't have any control over what the XML looks like.

However, the XML file that I am working off, EmailInfo is the document root and Contacts is under it.


-
blah, blah (indented 3 spaces)
blah blah (indented 3 spaces)
- (indented 3 spaces)
- (indented 5 spaces)
blah, blah (indented 7 spaces)
blah, blah (indented 7 spaces)
(indented 5 spaces)
(indented 3 spaces)



So I guess I need to get the children of the child ContactInfo, of the child Contacts?

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Yep, that sounds about right to me...

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Yep, that sounds about right to me...

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Below is the XML file I have and I still cannot get the second Contact Info.
I have tried Child By Name, Sibling by Name, Next Child. Whatever I do, I just cannot get the second Contact Info information. Any other suggestions?





L


T








LT@lsystems.com










(800) 886-9999

(610) 555-1414
(610) 555-1414






You


Are








you@systems.com










(610) 555-1212









[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Below is the XML file I have and I still cannot get the second Contact Info.
I have tried Child By Name, Sibling by Name, Next Child. Whatever I do, I just cannot get the second Contact Info information. Any other suggestions?





L


T








LT@lsystems.com










(800) 886-9999

(610) 555-1414
(610) 555-1414






You


Are








you@systems.com










(610) 555-1212









[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Below is the XML file I have and I still cannot get the second Contact Info.
I have tried Child By Name, Sibling by Name, Next Child. Whatever I do, I just cannot get the second Contact Info information. Any other suggestions?





L


T








LT@lsystems.com










(800) 886-9999

(610) 555-1414
(610) 555-1414






You


Are








you@systems.com










(610) 555-1212









[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Try working through the file using Acucorp's sample program. This should show you the correct sequence of C$XML commands to use. Do you need the compiled object?

My approach would be:-
1. Parse the file giving you the handle to . Save this handle as A.
2. Get-1st-Child of A should return the handle to . Save this handle as B.
3. Get-1st-Child of B should return the handle to . Save this handle as C.
3. Get-Next-Sibling of C (in a loop) should return the remaining items.
4. When you've exhausted the children of "B", Get-Next-Sibling of "B" should return the next .

Saving the handles in an array is the trick (I've found). Occurrence 1 always points to the primary element (handle A above), occurrence 2 always points to the children of the primary, occurrence 3 always refers to grand-children, etc.

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Try working through the file using Acucorp's sample program. This should show you the correct sequence of C$XML commands to use. Do you need the compiled object?

My approach would be:-
1. Parse the file giving you the handle to . Save this handle as A.
2. Get-1st-Child of A should return the handle to . Save this handle as B.
3. Get-1st-Child of B should return the handle to . Save this handle as C.
3. Get-Next-Sibling of C (in a loop) should return the remaining items.
4. When you've exhausted the children of "B", Get-Next-Sibling of "B" should return the next .

Saving the handles in an array is the trick (I've found). Occurrence 1 always points to the primary element (handle A above), occurrence 2 always points to the children of the primary, occurrence 3 always refers to grand-children, etc.

Ian

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Ian,

I really appreciate all your help.
I will be posting another issue really soon.
Feel free to give your expertise.

Thank you, thank you, thank you.

[Migrated content. Thread originally posted on 07 September 2007]

Below is the XML file that I am parsing. I am performing the following code, but it will not give me the Parent


000000 50001-GET-XML-FILE.
000000 CALL "C$XML" USING CXML-PARSE-FILE, PASSED-FILE-ALL.
000000 MOVE RETURN-CODE TO PARSER-HANDLE.
RRRRRR*Get Parent Name
RRRRRR CALL "C$XML" USING CXML-GET-PARENT, PARSER-HANDLE.
RRRRRR MOVE RETURN-CODE TO ELE-1-HANDLE.
RRRRRR CALL "C$XML" USING CXML-GET-DATA,
RRRRRR ELE-1-HANDLE, WS-NOTHING, WS-PARENT.

But nothing is returned in WS-PARENT. After the "C$XML" USING CXML-GET-PARENT, the RETURN-CODE is zero. Why is that giving me a Return Code of zero? I was expecting "EmailInfo" to be returned in WS-PARENT. What am I doing wrong? Or is there something wrong with the XML file?



C:\\temp\\test.pdf
New Mail
RECEIVED
09/06/2007
15:34
Me
You




Ian,

I really appreciate all your help.
I will be posting another issue really soon.
Feel free to give your expertise.

Thank you, thank you, thank you.