NewMom2Brandon
asked on
XML reading help(urgent)
Here is my xml file
<Config>
<PI>
<Id value="1" />
<Con>
<Type value="text" />
</Con>
</PI>
</Config>
The XML file loads fine. However when I try ti access the value from the node. I get nothing. I need to get the word text from the Type. What am I doing wrong or missing.
// Load XML document, loads into memory
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(sConfigFile);
}
catch (Exception ex)
{
System.Diagnostics.EventLo g.WriteEnt ry(this.To String(),
"Error XML reading" + ex.ToString(),
System.Diagnostics.EventLo gEntryType .Error);
}
//read the document and pull the node into the Text box
try
{
XmlNode TypeNode = xmlDoc.SelectSingleNode
("/Config/PI/Con/Type");
string Type = TypeNode.InnerText;
MessageBox.Show("results: " + Type, Text);
}
catch (Exception ex)
{
System.Diagnostics.EventLo g.WriteEnt ry(this.To String(),
"Error XML reading" + ex.ToString(),
System.Diagnostics.EventLo gEntryType .Error);
}
<Config>
<PI>
<Id value="1" />
<Con>
<Type value="text" />
</Con>
</PI>
</Config>
The XML file loads fine. However when I try ti access the value from the node. I get nothing. I need to get the word text from the Type. What am I doing wrong or missing.
// Load XML document, loads into memory
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(sConfigFile);
}
catch (Exception ex)
{
System.Diagnostics.EventLo
"Error XML reading" + ex.ToString(),
System.Diagnostics.EventLo
}
//read the document and pull the node into the Text box
try
{
XmlNode TypeNode = xmlDoc.SelectSingleNode
("/Config/PI/Con/Type");
string Type = TypeNode.InnerText;
MessageBox.Show("results: " + Type, Text);
}
catch (Exception ex)
{
System.Diagnostics.EventLo
"Error XML reading" + ex.ToString(),
System.Diagnostics.EventLo
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER