Databases Reference
In-Depth Information
Attributes can be assigned using XmlElment.SetAttribute(localname, value) and
Element values can be assigned using XmlElement.InnerXml = value.
Example 6-12 Creating new info XML document
public static XmlDocument CreateCustXML(String icid,String iname,
String icountry, String istreet, String icity, String iprov, String
ipcode, String iptype, String iphone)
{
XmlDocument custXmlDoc = new XmlDocument();
XmlElement customerinfo =
custXmlDoc.CreateElement("customerinfo");
custXmlDoc.AppendChild(customerinfo);
customerinfo.SetAttribute("xmlns", "http://posample.org");
customerinfo.SetAttribute("Cid", icid);
XmlElement name = custXmlDoc.CreateElement("name");
customerinfo.AppendChild(name);
name.InnerXml = iname;
XmlElement addr = custXmlDoc.CreateElement("addr");
customerinfo.AppendChild(addr);
addr.SetAttribute("country", icountry);
XmlElement street = custXmlDoc.CreateElement("street");
addr.AppendChild(street);
street.InnerXml = istreet;
XmlElement city = custXmlDoc.CreateElement("city");
addr.AppendChild(city);
city.InnerXml = icity;
XmlElement provstate = custXmlDoc.CreateElement("prov-state");
addr.AppendChild(provstate);
provstate.InnerXml = iprov;
XmlElement pcode = custXmlDoc.CreateElement("pcode-zip");
addr.AppendChild(pcode);
pcode.InnerXml = ipcode;
XmlElement phone = custXmlDoc.CreateElement("phone");
customerinfo.AppendChild(phone);
phone.SetAttribute("type", iptype);
phone.InnerXml = iphone;
Search WWH ::




Custom Search