Hi Everyone, I have part of XmlDocument Example.xml as given below:
<rapaine dotoc="palin" domap="rattmin">
<derif meet="local" />
<derif meet="intro" />
.
.
.
</rapaine>
Here i am creating a Nodelist and fetching the element raplin to get its attributes.
Now i want to make sure that whether the attributes 'dotoc' and 'domap' are the attributes of rapaine with respective values which are always fixed.Then only i can access the childNodes 'deriff' with its attribute 'meet'. here the value only changes.
i have written a part of code there are no compile errors but on debugging i found that its not going inside the for loop to check its attributes and child nodes.
XmlNodeList listOfSpineRootNodes = opfXmlDoc.GetElementsByTagName("rapine");
for (int x = 0; x < listOfSpineRootNodes.Count; x++)
{
XmlAttributeCollection spineAttributes = listOfSpineRootNodes[x].Attributes;
string id = spineAttributes[0].Value;
if (spineAttributes != null)
{
XmlNode attrToc = spineAttributes.GetNamedItem("dotoc");
XmlNode attrPageMap = spineAttributes.GetNamedItem("domap");
if (attrToc.Value == "palin" && attrPageMap.Value == "rattmine")
{
if (listOfSpineRootNodes != null)
{
foreach (XmlNode spineNodeRoot in listOfSpineRootNodes)
{
XmlNodeList listOfSpineItemNodes = spineNodeRoot.ChildNodes;
if (listOfSpineItemNodes != null)
{
foreach (XmlNode spineItemNode in listOfSpineItemNodes)
{
if (spineItemNode.NodeType == XmlNodeType.Element
&& spineItemNode.Name == "derif")
{
XmlAttributeCollection spineItemAttributes = spineItemNode.Attributes;
if (spineItemAttributes != null)
{
XmlNode attrIdRef = spineItemAttributes.GetNamedItem("meet");
if (attrIdRef != null)
{
spineListOfSmilFiles.Add(attrIdRef.Value);
}
}
}
}
}
}
}
}
}
Can you please tell me where i am going wrong.. Thanks....