Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12XML11-14-2011Opening DiscussionMinute essay comments:Can you write web pages using XML?Discrete and 1120 in the major/minor.FYs in 3194. Role of 3194.ASIMO is made by Honda, not sponsored.What were my influences for CS?What is the wackiest programming error I've ever seen?Assignment #2 grades should be expected this week.MotivationWe have been using “flat” text files to store things.Advantage: it is human readable and simple.Disadvantages: everything else.SlowLargeLacks meaningHard to editHard to debugXMLThe eXtensible Markup Language (XML) is a standard for text encoding of data.If you have ever done HTML, XML is similar. XHTML is HTML that follows the XML standard.The advantage of XML is that it can encode pretty much anything and it is human readable text.The downside is that it can be very verbose.Composed of markup (between < and > or & and ;) or content (anything not markup).TagsThe primary markup used in XML is the tag.A tag begins with a < and ends with a >.There are three types of tags.Start-tag: <student>End-tag: </student>Empty-element tag: <quiz/>ElementsThe structure of XML documents comes primarily from elements.An element is one of the following:Everything from a start-tag to the matching end-tag.An empty-element tag.Elements have to be properly nested. The nesting can imply information.AttributesAn attribute is a name value pair.They can be put in start-tags or empty-element tags.Examples:<student name=”Jason” id=”0123456”><quiz grade=”55”/>XML DeclarationAn XML file can begin with a declaration telling information about it.<?xml version="1.0" encoding="UTF-8" ?>We won't worry about these in this class.XML in ScalaThe Scala language supports XML at the language level.Go to the REPL and enter some XML.There is a scala.xml package that contains the libraries for XML.The NodeSeq, Node, and Elem types are particularly useful. I'll typically just use the word Node to describe something from the XML.So is the XML object.The XML ObjectThe loadFile method can be passed a file name and it will read in the file and return a NodeSeq that allows you to get to the contents.There is also a save method that takes a file name and an XML node and writes it to file.Using \ and \\Use the \ operation on a node to search for the occurrences of something at the top level.The second argument is a string.Normal string searches for tags with that label.If the string starts with @ it searches for attributes.Use \\ to search deeply.Minute EssayQuestions about XML?Valero will be presenting at the ACM meeting starting at
View Full Document