TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chantal Decraie
NA
20
1.6k
How to change innertext of an xml file
Feb 20 2017 7:00 AM
Hi,
Now that I can read my xml-file from my richtextbox I would like to change some innertext in the childnodes and whatch the changes in my richtextbox. How should I do this please? Because my code isn't working.
//Read selected file
.
XmlDocument
doc =
new
XmlDocument
();
doc.LoadXml(richTextBox1.Text);
XmlNodeList
nodeList = doc.DocumentElement.SelectNodes(
"/AnXMLTestFile/"
);
//<== error message
"Expression must evaluate to a node-set."
//find the node to change the content
//if node is not present, do nothing
foreach
(
XmlNode
xNode
in
nodeList)
{
if
(xNode.ParentNode.Attributes[
"HeaderBEDocument"
].Value !=
""
)
{
doc.SelectSingleNode(
"Identification"
).InnerText =
"string"
;
doc.SelectSingleNode(
"SCI"
).InnerText =
"string"
;
doc.SelectSingleNode(
"ReferenceType"
).InnerText =
"string"
;
doc.SelectSingleNode(
"CCType"
).InnerText =
"AA"
;
}
else
{ }
//do nothing
}
Can someone help me please?
Thanks in advance.
Reply
Answers (
2
)
Three tier Architecture
Dynamic Image Add in Email body