473,324 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Adding attribute to the parentnode of text node

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
May 26 '08 #1
1 2106
jkmyoung
2,057 Expert 2GB
First off, you probably shouldn't be using an XmlReader which is a read-only class. Is it possible for you to use something else, or is your code deeply routed in this?
May 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael Hill | last post by:
I have this code that adds a table row and within the cells I create some input elements. When I go back using javascript the functionaliuty is seeing the form element. Anyone tell why I can see...
8
by: Mikey | last post by:
I have an XML document as follows: <Menu> <Group> <Item Text="About Us" AccessRoles="All"> <Group> <Item Text="Option 1" AccessRoles="All" /> <Item Text="Option 2" AccessRoles="All" /> <Item...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
2
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so...
2
by: DanielLinn | last post by:
I'm getting an error in IE 6.0.2800 that says "Error: Not implemented." when I try to get a parent. Does it whether or not 'compatibility mode' is on. Here's my code: <!DOCTYPE html PUBLIC...
2
by: amattie | last post by:
Anyone know what the specific difference is between the offsetParent and parentNode properties of a DOM element are? Mozilla's docs on the DOM element...
2
by: npm | last post by:
I'm trying to display XML nodes whose parent node has a certain attribute (or attribute value). I have one code that works in Firefox, but not IE and another code that works in IE, but not Firefox. ...
1
by: weird0 | last post by:
Here is the code that i have been using to add nodes dynamically, but I cant see any child nodes being displayed on the treeView... all i can see the root node "Network". I have been trying to...
3
by: jeddiki | last post by:
Hi, I am using this script which is nearly working correctly, but not quite! When a user selects some text from the web-page and copies it, the script is supposed to pick up the current...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.