jambalapamba
Programmer
Hi
I am walking xml using c# and i want add attribute (style="text-decoration: line-through;" ) to the parent node of text node if the value meets some condition.
e.g if this element <div >include</div> as include doesn't contain "read" i want <div style="text-decoration: line-through;">include</div>
Here is wht i am doing
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(xmldoc);
XmlNodeReader reader = new XmlNodeReader(xDoc);
while (!reader.EOF)
{
reader.Read();
XmlNodeType nodeType = reader.NodeType;
Console.WriteLine(reader.Value);
if (nodeType == XmlNodeType.Element)
{
for (int i = 0; i < reader.AttributeCount; i++)
{
//do something
}
}
else if (nodeType == XmlNodeType.Text)
{
if (reader.Value.ToString().Contains("read"))
{
//do something
}
else
{
//i want to add attribute to the parent element of this text node
}
}
} //end while
Can any one give me suggestiongs how to do it
Thank you
I am walking xml using c# and i want add attribute (style="text-decoration: line-through;" ) to the parent node of text node if the value meets some condition.
e.g if this element <div >include</div> as include doesn't contain "read" i want <div style="text-decoration: line-through;">include</div>
Here is wht i am doing
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(xmldoc);
XmlNodeReader reader = new XmlNodeReader(xDoc);
while (!reader.EOF)
{
reader.Read();
XmlNodeType nodeType = reader.NodeType;
Console.WriteLine(reader.Value);
if (nodeType == XmlNodeType.Element)
{
for (int i = 0; i < reader.AttributeCount; i++)
{
//do something
}
}
else if (nodeType == XmlNodeType.Text)
{
if (reader.Value.ToString().Contains("read"))
{
//do something
}
else
{
//i want to add attribute to the parent element of this text node
}
}
} //end while
Can any one give me suggestiongs how to do it
Thank you