bkriekaard
10th July 2014, 12:31
Hello,
I have the following XML file:
<Details>
<Detail>
<ExpectedVisitsVisitElement
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VisitActivityStatus value="Unknown" xmlns="field" />
<CallReferenceNumber value="NLAMS2126706481" xmlns="field" />
<IMONumber value="9431836" xmlns="field" />
<AgentName value="Nissan Carrier Europe B.V." xmlns="field" />
<AgentTelephone value="0206139961" xmlns="field" />
</ExpectedVisitsVisitElement>
I've created a script to read all the values, but it seems it can be done in an easier way.
l.fp = seq.open(l.entry, "r")
l.xml.details = xmlRead(l.fp, err)
l.xml.detail = xmlFindFirstMatch("<Details><Detail>", l.xml.details)
while l.xml.detail > 0
l.xml.vIP.VisitsVisitElement = xmlGetFirstchild(l.xml.detail)
l.xml.num.childs = xmlGetNumChilds(l.xml.VIP.VisitsVisitElement)
l.xml.field = xmlGetFirstchild(l.xml.VIP.VisitsVisitElement)
xmlGetName(l.xml.field, l.xml.attribute.name)
xmlGetAttribute(l.xml.field, "value", l.xml.attribute.value )
if l.xml.attribute.name = "VisitActivityStatus" then
l.VisitActivityStatus = l.xml.attribute.value
endif
FOR l.xml.teller = 2 to l.xml.num.childs
l.xml.field = xmlGetRightSibling(l.xml.field)
xmlGetName(l.xml.field, l.xml.attribute.name)
xmlGetAttribute(l.xml.field, "value", l.xml.attribute.value )
ON CASE l.xml.attribute.name
CASE "CallReferenceNumber":
l.vnum = l.xml.attribute.value
break
CASE "IMONumber":
l.imon = l.xml.attribute.value
break
etc.etc.....
ENDCASE
ENDFOR
etc.etc.
------------
In previous versions I had a xml file with the following structure
<FIELD1>VALUE</FIELD1>
<FIELD2>VALUE</FIELD2>
<FIELD3>VALUE</FIELD3>
and then you can use: xmlGetDataElement(l.xml.detail, "FIELD1", l.vnum) to get the value
but know I have:
<VisitActivityStatus value="Unknown" xmlns="field" />
To read all the tags below: <ExpectedVisitsVisitElement
Is it right that I can only use "xmlGetFirstChild" to get the first, and use xmlGetRightSibling to go to the next one ?
somebody suggestions to make it easier ?
Thanks Bennie
I have the following XML file:
<Details>
<Detail>
<ExpectedVisitsVisitElement
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VisitActivityStatus value="Unknown" xmlns="field" />
<CallReferenceNumber value="NLAMS2126706481" xmlns="field" />
<IMONumber value="9431836" xmlns="field" />
<AgentName value="Nissan Carrier Europe B.V." xmlns="field" />
<AgentTelephone value="0206139961" xmlns="field" />
</ExpectedVisitsVisitElement>
I've created a script to read all the values, but it seems it can be done in an easier way.
l.fp = seq.open(l.entry, "r")
l.xml.details = xmlRead(l.fp, err)
l.xml.detail = xmlFindFirstMatch("<Details><Detail>", l.xml.details)
while l.xml.detail > 0
l.xml.vIP.VisitsVisitElement = xmlGetFirstchild(l.xml.detail)
l.xml.num.childs = xmlGetNumChilds(l.xml.VIP.VisitsVisitElement)
l.xml.field = xmlGetFirstchild(l.xml.VIP.VisitsVisitElement)
xmlGetName(l.xml.field, l.xml.attribute.name)
xmlGetAttribute(l.xml.field, "value", l.xml.attribute.value )
if l.xml.attribute.name = "VisitActivityStatus" then
l.VisitActivityStatus = l.xml.attribute.value
endif
FOR l.xml.teller = 2 to l.xml.num.childs
l.xml.field = xmlGetRightSibling(l.xml.field)
xmlGetName(l.xml.field, l.xml.attribute.name)
xmlGetAttribute(l.xml.field, "value", l.xml.attribute.value )
ON CASE l.xml.attribute.name
CASE "CallReferenceNumber":
l.vnum = l.xml.attribute.value
break
CASE "IMONumber":
l.imon = l.xml.attribute.value
break
etc.etc.....
ENDCASE
ENDFOR
etc.etc.
------------
In previous versions I had a xml file with the following structure
<FIELD1>VALUE</FIELD1>
<FIELD2>VALUE</FIELD2>
<FIELD3>VALUE</FIELD3>
and then you can use: xmlGetDataElement(l.xml.detail, "FIELD1", l.vnum) to get the value
but know I have:
<VisitActivityStatus value="Unknown" xmlns="field" />
To read all the tags below: <ExpectedVisitsVisitElement
Is it right that I can only use "xmlGetFirstChild" to get the first, and use xmlGetRightSibling to go to the next one ?
somebody suggestions to make it easier ?
Thanks Bennie