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 200 | Next

Scott Klein

"Professional LINQ"

Thus, you
must specify a new element to be created in the place of the old element.
A similar operation can be done with attributes using the SetAttributeValue method. In the following
example, notice that the attribute id has a value of 1.
XElement employee = new XElement("Employees",
new XElement("Employee",
new XAttribute("id", "1"),
new XElement("Name", "Scott"),
new XElement("Address", "555 Main St."),
new XElement("City", "Wellington"),
new XElement("State", "FL")
)
);
When you execute the following statement, the attribute value is changed to 3.
The SetAttributeValue method changes the value of the id attribute to 3.
employee.Element("Employee").SetAttributeValue("id", "3");
The SetElementValue method is also available to you. It??™s a method of the XElement class and provides
the capability to set the value of a child element, or to add or remove a child element. For example, the following
creates a simple XML fragment and then uses the SetElementValue() method
to update the Address node value:
XElement employee = new XElement("Employees",
new XElement("Employee",
new XAttribute("id", "1"),
new XElement("Name", "Scott"),
new XElement("Address", "555 Main St.


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