EDN Admin
Well-known member
Hi All,
I am having the following funtion to validate the xml but I want to track the each and every element of xml whether it is valid/Invalid can you please tell me how to Identify the node is valid/not?
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <font size="2" color="#0000ff" style="color:#0000ff; font-size:x-small
Private
</font>
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Sub<span style="font-size:x-small Validate_1(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
filename <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small MemoryStream,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small xsc
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlSchemaCollection)<font size="2" style="font-size:x-small
m_success =
</font><font size="2" color="#0000ff <font size="2" color="#0000ff True</font></font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
Console.WriteLine()
Console.WriteLine("Validating XML file {0}...", filename.ToString())
filename.Position = 0
<font size="2" style="font-size:x-small
reader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlTextReader(filename)</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small nodenm
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff String</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Create a validating reader.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
vreader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlValidatingReader(reader)</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Use the schemas stored in the schema collection.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
vreader.Schemas.Add(xsc)
<font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Set the validation event handler.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddHandler<span style="font-size:x-small vreader.ValidationEventHandler,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddressOf<font size="2 ValidationCallBack</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Read and validate the XML data.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While<font size="2 vreader.Read()</font><span style="font-size:x-small <font size="2" style="font-size:x-small
nodenm = vreader.Name
</font><font size="2" color="#008000 <font size="2" color="#008000 LocalName())</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
MsgBox(nodenm)
<font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff While</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
MsgBox("Validation finished. Validation" & m_success)
<hr class="sig Manoj A. Raut
View the full article
I am having the following funtion to validate the xml but I want to track the each and every element of xml whether it is valid/Invalid can you please tell me how to Identify the node is valid/not?
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <font size="2" color="#0000ff" style="color:#0000ff; font-size:x-small
Private
</font>
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Sub<span style="font-size:x-small Validate_1(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
filename <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small MemoryStream,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small xsc
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlSchemaCollection)<font size="2" style="font-size:x-small
m_success =
</font><font size="2" color="#0000ff <font size="2" color="#0000ff True</font></font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
Console.WriteLine()
Console.WriteLine("Validating XML file {0}...", filename.ToString())
filename.Position = 0
<font size="2" style="font-size:x-small
reader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlTextReader(filename)</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small nodenm
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff String</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Create a validating reader.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
vreader =
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<font size="2 XmlValidatingReader(reader)</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Use the schemas stored in the schema collection.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
vreader.Schemas.Add(xsc)
<font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Set the validation event handler.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddHandler<span style="font-size:x-small vreader.ValidationEventHandler,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddressOf<font size="2 ValidationCallBack</font><span style="font-size:x-small <font size="2" style="font-size:x-small
</font><font size="2" color="#008000 <font size="2" color="#008000 Read and validate the XML data.</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small <font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While<font size="2 vreader.Read()</font><span style="font-size:x-small <font size="2" style="font-size:x-small
nodenm = vreader.Name
</font><font size="2" color="#008000 <font size="2" color="#008000 LocalName())</font></font><span style="color:#008000; font-size:x-small <span style="font-size:x-small
MsgBox(nodenm)
<font size="2" style="font-size:x-small
</font><span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<font size="2" color="#0000ff <font size="2" color="#0000ff While</font></font><span style="color:#0000ff; font-size:x-small <span style="font-size:x-small
MsgBox("Validation finished. Validation" & m_success)
<hr class="sig Manoj A. Raut
View the full article