
Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
When I run this I get an exception "Data at the root level is invalid".
Any suggestions?
> > How can I iterate through using C# and change "Stri" to "ABC" ?
>
> XmlDocument doc = new XmlDocument();
> //Load XML
> doc.LoadXml(xml);
> XmlNodeList list =
doc.SelectNodes("//*[@code_description_type='description']//Code[.='Stri']")
;
> foreach (XmlNode node in list)
> node.FirstChild.Value = "ABC";
Oleg Tkachenko - 29 Jul 2003 19:42 GMT
> When I run this I get an exception "Data at the root level is invalid".
> Any suggestions?
Most likely you are trying to load XML by URL using LoadXML method. My
mistake, I just tested it loading your XML as string. Use ordinar Load
method instead.

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Mike McCarthy - 29 Jul 2003 19:56 GMT
Thanks the code runs.
I noticed though that my file has not been changed.
Should I be using XmlWriter ?
> > When I run this I get an exception "Data at the root level is invalid".
> > Any suggestions?
> Most likely you are trying to load XML by URL using LoadXML method. My
> mistake, I just tested it loading your XML as string. Use ordinar Load
> method instead.
Oleg Tkachenko - 29 Jul 2003 20:17 GMT
> I noticed though that my file has not been changed.
Sure, you have to save modified document using Save method, e.g.
doc.Save("foo.xml");

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Mike McCarthy - 29 Jul 2003 20:27 GMT
Thank you very much.
> > I noticed though that my file has not been changed.
> Sure, you have to save modified document using Save method, e.g.
> doc.Save("foo.xml");