[Message Deleted]
-
Since
DOC
node doesn't have child, you only need one loop which iterates the child nodes ofBIBLE
. See the following codefor (int i = 0; i < bNode.ChildNodes.Count; i++)
{
XmlNode node = bNode.ChildNodes[i];
string strElement = node.Name;
if (strElement.ToLower().Trim() == "doc")
{
string strDocClientID = node.Attributes["CLIENT_ID"].Value;
string strDocMatterID = node.Attributes["MATTER_ID"].Value;
string strDocNumber = node.Attributes["DOCNUMBER"].Value;
string strDocName = node.Attributes["DOCNAME"].Value;
}
}This can be done in a better way if you use
XPath
. :)Navaneeth How to use google | Ask smart questions
-
Get a XmlElement and SelectSingleNode of that, instead of the XmlDocument. I am not sure why it is returning SECOND, I am beginner, I had this information thought of sharing, might help you, Let me know if it do help.
XmlDocument doc = new XmlDocument();
doc.Load(strFullPath);**XmlElement root = doc.DocumentElement;
XmlNode bNode = root.SelectSingleNode("BIBLE");**
string strBibleClientID = doc.DocumentElement.GetAttribute("CLIENT_ID");
string strBibleMatterID = doc.DocumentElement.GetAttribute("MATTER_ID");
string strBibleDocNumber = doc.DocumentElement.GetAttribute("DOCNUMBER");for (int i = 0; i < bNode.ChildNodes.Count; i++)
{
XmlNode bibleNode = bNode.ChildNodes[i];//number of elements per Bible...
int intElements = bibleNode.ChildNodes.Count;//Go through the BIBLE node...
for (int x = 0; x < intElements; x++)
{
//pull out each element...
string strElement = bibleNode.ChildNodes[x].Name.ToString();if (strElement.ToLower().Trim() == "doc")
{
string strDocClientID = bibleNode.ChildNodes[x].Attributes["CLIENT_ID"].Value;
string strDocMatterID = bibleNode.ChildNodes[x].Attributes["MATTER_ID"].Value;
string strDocNumber = bibleNode.ChildNodes[x].Attributes["DOCNUMBER"].Value;
string strDocName = bibleNode.ChildNodes[x].Attributes["DOCNAME"].Value;}
}
} -
Since
DOC
node doesn't have child, you only need one loop which iterates the child nodes ofBIBLE
. See the following codefor (int i = 0; i < bNode.ChildNodes.Count; i++)
{
XmlNode node = bNode.ChildNodes[i];
string strElement = node.Name;
if (strElement.ToLower().Trim() == "doc")
{
string strDocClientID = node.Attributes["CLIENT_ID"].Value;
string strDocMatterID = node.Attributes["MATTER_ID"].Value;
string strDocNumber = node.Attributes["DOCNUMBER"].Value;
string strDocName = node.Attributes["DOCNAME"].Value;
}
}This can be done in a better way if you use
XPath
. :)Navaneeth How to use google | Ask smart questions