Chapter 3: Edit XML file records
Use C # To edit XML files. The most convenient method is to use DATASET.
We continue to use the XML file in the previous article, as follows: <users>
<Xs: schema id = "users" xmlns = "" xmlns: xs = "http://www.w3.org/2001/XMLSchema" xmlns: msdata = "urn: schemas-microsoft-com: xml-msdata">
<Xs: element name = "users" msdata: IsDataSet = "true" msdata: Locale = "zh-CN">
<Xs: complexType>
<Xs: choice maxOccurs = "unbounded">
<Xs: element name = "user">
<Xs: complexType>
<Xs: sequence>
<Xs: element name = "userName" type = "xs: string" minOccurs = "0" msdata: Ordinal = "0"/>
<Xs: element name = "userPass" type = "xs: string" minOccurs = "0" msdata: Ordinal = "1"/>
</Xs: sequence>
<Xs: attribute name = "id" type = "xs: string"/>
</Xs: complexType>
</Xs: element>
</Xs: choice>
</Xs: complexType>
</Xs: element>
</Xs: schema>
<User id = "1">
<UserName> outrace </userName>
<UserPass> mypass </userPass>
</User>
<User id = "2">
<UserName> trace </userName>
<UserPass> mypass </userPass>
</User>
<User id = "3">
<UserName> new user </userName>
<UserPass> new passwd </userPass>
</User>
</Users>
Then, create an XML file with the following content: <% @ Import Namespace = "System. IO" %>