SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 199 | Next

Scott Klein

"Professional LINQ"


Wellington
WA
33414


In the following code, the first line identifies the element whose contents will be replaced, and the second
line employs the ReplaceWith() method to specify the replacement content:
XElement st = employee.Element("Employee").Element("State");
st.ReplaceWith(new XElement("State", "FL"));
Here??™s the resulting XML:


Scott
555 Main St.

Wellington
FL
33414


Notice that the value of the element has been changed from WA to FL.
What happens if you use the following code to replace an element value?
st.ReplaceWith("FL");
ReplaceWith()deletes the specified node and replaces it with the specified content:


Scott
114
Chapter 5: Understanding LINQ to XML
555 Main St.

WellingtonFL


The element is deleted and simply replaced with the text FL and not a new node.


Pages:
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6