Error in get ChildNode of the current node
-
Hi, My XML looks like ABC,XYZ In my coding I getting this using XmlNodeList allNodes= XmlDoc.GetElementsByTagName("Book"); I am checking whether this any childnodes exists for this using XmlNode child=allNodes[0].ChildNodes[0]; string Childname= child.Name; I am getting this(childname as) "#text" ,though no childnode is there in my XML
-
Hi, My XML looks like ABC,XYZ In my coding I getting this using XmlNodeList allNodes= XmlDoc.GetElementsByTagName("Book"); I am checking whether this any childnodes exists for this using XmlNode child=allNodes[0].ChildNodes[0]; string Childname= child.Name; I am getting this(childname as) "#text" ,though no childnode is there in my XML
Both your allNodes object and the ChildNodes property of allNodes is a XMLNodeList. Thus, both allNodes and ChildNodes have a Count property that you can check to verify if GetElementByTagName returned any nodes or if ChildNodes contains any nodes.
"We make a living by what we get, we make a life by what we give." --Winston Churchill