Class Notes (806,625)
Canada (492,359)
COMP 1020 (6)

review 3.docx

3 Pages
Unlock Document

University of Manitoba
Computer Science
COMP 1020
Pourang Irani

Order is not important when dealing with attributes. XML parsers treat attributes as a collection of unordered information relating to an element. On the other hand, the order of elements often is important. Thus, if you need a way of arranging information and preserving its order, or if you have a list of items with the same name, then use elements, not attributes. You can also add comments to an XML document. Comments go just about anywhere and are ignored for data processing purposes. Comments are bracketed by the character sequences. The following listing includes three valid comments: 49.33 True 3 The only place you can’t put a comment is embedded within a start or end tag (as in ). Here’s an example that creates a simple version of the SuperProProductList document: // Place the file in the App_Data subfolder of the current website. // The System.IO.Path class makes it easy to build the full file name. string file = Path.Combine(Request.PhysicalApplicationPath, @"App_Data\SuperProProductList.xml"); FileStream fs = new FileStream(file, FileMode.Create); XmlTextWriter w = new XmlTextWriter(fs, null); w.WriteStartDocument(); w.WriteStartElement("SuperProProductList"); w.WriteComment("This file generated by the XmlTextWriter class."); // Write the first product. w.WriteStartElement("Product"); w.WriteAttributeString("ID", "1"); w.WriteAttributeString("Name", "Chair"); w.WriteStartElement("Price"); w.WriteString("49.33"); w.WriteEndElement(); w.WriteEndElement(); // Write the second product. w.WriteStartElement("Product"); w.WriteAttributeString("ID", "2"); w.WriteAttributeString("Name", "Car"); w.WriteStartElement("Price"); w.WriteString("43399.55"); w.WriteEndElement(); w.WriteEndElement(); // Write the third product. w.WriteStartElement("Product"); w.WriteAttributeString("ID", "3"
More Less

Related notes for COMP 1020

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.