I have an xml file that looks like this
<?xml version="1.0"?>
<Users>
<Message>
<type>Success</type>
<StudentId>123456</StudentId>
<UserName>cpeters</UserName>
<MessageCode>0</MessageCode>
<Section_Number>111</Section_Number>
</Message>
<Message>
<type>Failure</type>
<StudentId>456733</StudentId>
<UserName>jmartin</UserName>
<MessageCode>0</MessageCode>
<Section_Number>129</Section_Number>
</Message>
<Message>
<type>Success</type>
<StudentId>764523</StudentId>
<UserName>jhart</UserName>
<MessageCode>0</MessageCode>
<Section_Number>149</Section_Number>
</Message>
</Users>
and I parse it using the following code....
set xmlDoc=CreateObject("Microsoft.XMLDOM"
xmlDoc.async="false"
xmlDoc.load("TheAmericanCollege.xml"
dim intnumber, intnumberFail
intnumber=0
intnumberFail=0
for each x in xmlDoc.documentElement.childNodes
if (x.selectSingleNode("type"
.firstChild.nodeValue="Success"
then
intnumber=intnumber+1
elseif (x.selectSingleNode("type"
.firstChild.nodeValue="Failure"
then
intnumberFail=intnumberFail+1
end if
next
arraysiz=intnumber-1
arraysizfail=intnumberFail-1
redim arraystudent(arraysiz,3)
redim arraystudentfail(arraysizfail,3)
for each y in xmlDoc.documentElement.childNodes
if (y.selectSingleNode("type"
.firstChild.nodeValue="Success"
then
arraystudent(arraysiz,0)=y.selectSingleNode("UserName"
.firstChild.nodeValue
arraystudent(arraysiz,1)=y.selectSingleNode("Section_Number"
.firstChild.nodeValue
arraystudent(arraysiz,2)=y.selectSingleNode("StudentId"
.firstChild.nodeValue
arraystudent(arraysiz,3)=y.selectSingleNode("MessageCode"
.firstChild.nodeValue
arraysiz=arraysiz-1
elseif (y.selectSingleNode("type"
.firstChild.nodeValue="Failure"
then
arraystudentfail(arraysizfail,0)=y.selectSingleNode("UserName"
.firstChild.nodeValue
arraystudentfail(arraysizfail,1)=y.selectSingleNode("Section_Number"
.firstChild.nodeValue
arraystudentfail(arraysizfail,2)=y.selectSingleNode("StudentId"
.firstChild.nodeValue
arraystudentfail(arraysizfail,3)=y.selectSingleNode("MessageCode"
.firstChild.nodeValue
arraysizfail=arraysizfail-1
end if
next
Problem is now my file is being changed.... to
<?xml version="1.0"?>
<Users>
<Message>
<type>Success</type>
<StudentId>123456</StudentId>
<UserName>cpeters</UserName>
<MessageCode>0</MessageCode>
<Section_Number>111</Section_Number>
</Message>
<Message>
<type>Failure</type>
<StudentId>456733</StudentId>
<UserName>jmartin</UserName>
<MessageCode>0</MessageCode>
<Section_Number>129</Section_Number>
</Message>
<Message>
<type>Success</type>
<Section>102</Section>
<client_section_id></client_section_id>
<course_id>325</course_id>
<MessageCode>0</MessageCode>
</Message>
</Users>
The problem is that nowthe file changed from all users to sections as well...
I need to be able to identify whether the seconfd node is Scetion or StudentId.
How can I do this...
<?xml version="1.0"?>
<Users>
<Message>
<type>Success</type>
<StudentId>123456</StudentId>
<UserName>cpeters</UserName>
<MessageCode>0</MessageCode>
<Section_Number>111</Section_Number>
</Message>
<Message>
<type>Failure</type>
<StudentId>456733</StudentId>
<UserName>jmartin</UserName>
<MessageCode>0</MessageCode>
<Section_Number>129</Section_Number>
</Message>
<Message>
<type>Success</type>
<StudentId>764523</StudentId>
<UserName>jhart</UserName>
<MessageCode>0</MessageCode>
<Section_Number>149</Section_Number>
</Message>
</Users>
and I parse it using the following code....
set xmlDoc=CreateObject("Microsoft.XMLDOM"
xmlDoc.async="false"
xmlDoc.load("TheAmericanCollege.xml"
dim intnumber, intnumberFail
intnumber=0
intnumberFail=0
for each x in xmlDoc.documentElement.childNodes
if (x.selectSingleNode("type"
intnumber=intnumber+1
elseif (x.selectSingleNode("type"
intnumberFail=intnumberFail+1
end if
next
arraysiz=intnumber-1
arraysizfail=intnumberFail-1
redim arraystudent(arraysiz,3)
redim arraystudentfail(arraysizfail,3)
for each y in xmlDoc.documentElement.childNodes
if (y.selectSingleNode("type"
arraystudent(arraysiz,0)=y.selectSingleNode("UserName"
arraystudent(arraysiz,1)=y.selectSingleNode("Section_Number"
arraystudent(arraysiz,2)=y.selectSingleNode("StudentId"
arraystudent(arraysiz,3)=y.selectSingleNode("MessageCode"
arraysiz=arraysiz-1
elseif (y.selectSingleNode("type"
arraystudentfail(arraysizfail,0)=y.selectSingleNode("UserName"
arraystudentfail(arraysizfail,1)=y.selectSingleNode("Section_Number"
arraystudentfail(arraysizfail,2)=y.selectSingleNode("StudentId"
arraystudentfail(arraysizfail,3)=y.selectSingleNode("MessageCode"
arraysizfail=arraysizfail-1
end if
next
Problem is now my file is being changed.... to
<?xml version="1.0"?>
<Users>
<Message>
<type>Success</type>
<StudentId>123456</StudentId>
<UserName>cpeters</UserName>
<MessageCode>0</MessageCode>
<Section_Number>111</Section_Number>
</Message>
<Message>
<type>Failure</type>
<StudentId>456733</StudentId>
<UserName>jmartin</UserName>
<MessageCode>0</MessageCode>
<Section_Number>129</Section_Number>
</Message>
<Message>
<type>Success</type>
<Section>102</Section>
<client_section_id></client_section_id>
<course_id>325</course_id>
<MessageCode>0</MessageCode>
</Message>
</Users>
The problem is that nowthe file changed from all users to sections as well...
I need to be able to identify whether the seconfd node is Scetion or StudentId.
How can I do this...