C# xml Changing value of single Node

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi im trying to change value of single node in my xml file but im always getting Not Supported Exception.
here is a code :

<div style="color:Black;background-color:White; <pre>
XPathDocument oXPathDocument = <span style="color:Blue; new XPathDocument(<span style="color:#A31515; "dane.xml");
XPathNavigator oXPathNavigator = oXPathDocument.CreateNavigator();
XPathNodeIterator oPersonNodesIterator = oXPathNavigator.Select(<span style="color:#A31515; "/Role/Rola");
Console.WriteLine(<span style="color:#A31515; "W pliku XML, znaleziono dane następujących osób: ");
<span style="color:Blue; foreach (XPathNavigator oCurrentPerson <span style="color:Blue; in oPersonNodesIterator)
{

<span style="color:Blue; if (oCurrentPerson.SelectSingleNode(<span style="color:#A31515; "name").Value == x)
oCurrentPerson.SelectSingleNode(<span style="color:#A31515; "baza").SetValue(<span style="color:#A31515; "new text");

}
[/code]
<br/>
<br/>

and here is xml structure :

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; Role <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; " <span style="color:Red; xmlns:xsd<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Rola<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; name<span style="color:Blue; >niezalogowany<span style="color:Blue; </<span style="color:#A31515; name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; user<span style="color:Blue; >niezalogowany<span style="color:Blue; </<span style="color:#A31515; user<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; haslo<span style="color:Blue; >niezalogowany<span style="color:Blue; </<span style="color:#A31515; haslo<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; serwer<span style="color:Blue; >SZPIC_LAPTOP<span style="color:Blue; </<span style="color:#A31515; serwer<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; baza<span style="color:Blue; >Okulistyka<span style="color:Blue; </<span style="color:#A31515; baza<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Rola<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Role<span style="color:Blue; >
[/code]
<br/>
Thanks!


View the full article
 
Back
Top