G
Guest
Working with my first XML file and the first time I have used the
XmlTextReader class. Reading a book on this subject, I have constructed code
which I thought would navigate thru the file and retrieve the values for each
of the "nodes".
Running the debugger, I can see that I am navigating to each of the nodes,
but when I look at the "Value" property, it is empty. I'm not sure what I am
doing wrong.
Here is a snipit of my XML file looks like the following....
<Program>
<ProgramName>PG8NS000</ProgramName>
<Description>Update Activity on Final Approval - unable to locate specs
- see TSO90(DPG00000.OBSOLETE.APSPROG)</Description>
<Location></Location>
<Status>Inactive</Status>
</Program>
<Program>
<ProgramName>PG9SB009</ProgramName>
<Description>Remove Errors on O&B Except D0001</Description>
<Location>../Attachments/Specs/Archive/PS_PG9SB009.doc</Location>
<Status>Inactive</Status>
</Program>
Snipit of my code looks like the following....
while (rdr.Read())
{
if (rdr.NodeType == XmlNodeType.Text)
{
switch (rdr.Name)
{
case "Program":
row = _DtPrograms.NewRow();
break;
case "ProgramName":
row["ProgramName"] = rdr.Value;
break;
case "Description":
row["Description"] = rdr.Value;
break;
case "Status":
row["Status"] = rdr.Value;
break;
case "Location":
row["Location"] = rdr.Value;
break;
}
}
else if (rdr.NodeType == XmlNodeType.EndElement && rdr.Name ==
"Program")
{
_DtPrograms.Rows.Add(row);
}}
Thanks in advance for your assistance!!!
XmlTextReader class. Reading a book on this subject, I have constructed code
which I thought would navigate thru the file and retrieve the values for each
of the "nodes".
Running the debugger, I can see that I am navigating to each of the nodes,
but when I look at the "Value" property, it is empty. I'm not sure what I am
doing wrong.
Here is a snipit of my XML file looks like the following....
<Program>
<ProgramName>PG8NS000</ProgramName>
<Description>Update Activity on Final Approval - unable to locate specs
- see TSO90(DPG00000.OBSOLETE.APSPROG)</Description>
<Location></Location>
<Status>Inactive</Status>
</Program>
<Program>
<ProgramName>PG9SB009</ProgramName>
<Description>Remove Errors on O&B Except D0001</Description>
<Location>../Attachments/Specs/Archive/PS_PG9SB009.doc</Location>
<Status>Inactive</Status>
</Program>
Snipit of my code looks like the following....
while (rdr.Read())
{
if (rdr.NodeType == XmlNodeType.Text)
{
switch (rdr.Name)
{
case "Program":
row = _DtPrograms.NewRow();
break;
case "ProgramName":
row["ProgramName"] = rdr.Value;
break;
case "Description":
row["Description"] = rdr.Value;
break;
case "Status":
row["Status"] = rdr.Value;
break;
case "Location":
row["Location"] = rdr.Value;
break;
}
}
else if (rdr.NodeType == XmlNodeType.EndElement && rdr.Name ==
"Program")
{
_DtPrograms.Rows.Add(row);
}}
Thanks in advance for your assistance!!!