XML Question
Posted: Fri Nov 08, 2019 12:19 am
I have been trying to work through an XML document to pull out specific data points.
I have been able to use revXMLChildNames to iterate a few layers deep, but when I try to go further, it seems to fail (it returns nothing).
This is the loop in question that is producing errors.
repeat for each line L in tComponents
repeat for each line E in tEntries
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody/" & \
L & "/section/" & E,return,"act",True) into tAct
end repeat
end repeat
To get the values for L and E, I used the following code that work.
--This is the initial breakdown of the document. It creates a separate tComponents node - tComponents[n]
--for each instance.
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody",return,"component",True) into tComponents
--This is the second breakdown of the document. It creates a separate tEntries node - tEntries[n] for
--each instance.
repeat for each line L in tComponents
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody/" & \
L & "/section" ,return,"entry",True) into tEntries
end repeat
I was wondering if someone had some advice. I have limited experience with LiveCode (a few months), and this is my first project with the XML library.
cutt<dot>ly/CeYk4VJ
Above is a link to the stack and a test XML file.
Thank you for any help. Ultimately, I want to try to iterate through the document and pull specific attributes and values out, but I need to figure out how to traverse it efficiently.
I have been able to use revXMLChildNames to iterate a few layers deep, but when I try to go further, it seems to fail (it returns nothing).
This is the loop in question that is producing errors.
repeat for each line L in tComponents
repeat for each line E in tEntries
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody/" & \
L & "/section/" & E,return,"act",True) into tAct
end repeat
end repeat
To get the values for L and E, I used the following code that work.
--This is the initial breakdown of the document. It creates a separate tComponents node - tComponents[n]
--for each instance.
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody",return,"component",True) into tComponents
--This is the second breakdown of the document. It creates a separate tEntries node - tEntries[n] for
--each instance.
repeat for each line L in tComponents
put revXMLChildNames(tXML,"ClinicalDocument/component/structuredBody/" & \
L & "/section" ,return,"entry",True) into tEntries
end repeat
I was wondering if someone had some advice. I have limited experience with LiveCode (a few months), and this is my first project with the XML library.
cutt<dot>ly/CeYk4VJ
Above is a link to the stack and a test XML file.
Thank you for any help. Ultimately, I want to try to iterate through the document and pull specific attributes and values out, but I need to figure out how to traverse it efficiently.