XML eXtensible Markup Language w3c standard Why? Store and transport data Easy data exchange Create more languages WSDL (Web Service Description Language) RDF (Resource Description Framework) RSS (Really Simple Syndication) Self-describing data Easy to learn Must learn
3 Major Components XML XSL (eXtensible Stylesheet Language) Style sheet language for XML documents XSD (XML Schema Definition) Describes the structure of an XML document
XML Document Tove Jani Reminder Don't forget me this weekend! Processing Instruction Comment Element Attribute
XML Documents Well formed and Valid Well formed Should only contain one root element All tags should have corresponding end tag Tags never overlap( … ) Attributes must be quoted Valid Must be well formed and conforms to the schema
XML Documents Has tree structure Tags are case sensitive is different from Comments
XML Elements Can contain Other elements Text Attributes Valid names,, Invalid names,,
XML elements and Attributes Data goes as elements john Meta data goes as attributes graph.gif
1.0 vs – everything not permitted is forbidden 1.1 – everything not forbidden is permitted 1.0 is compatible with 1.1, not vise-versa Forward compatible Does not affects to English documents
XML Namespaces There can be common elements in multiple domains File in hardware and office Employee data 25
XML Namespaces How to distinguish? Solution : namespaces Employee data 25
XML Parsers A piece of software which reads the content from the XML documents and present it to the application Implementing xml parser Java way SAX (Simple API for XML) DOM (Document Object Model) StAX (Streaming API for XML)
XML Parsers XML Parser Demos
XML Parsers FeatureStAXSAXDOM API TypePull, StreamingPush, StreamingIn memory tree Ease of UseHighMediumHigh XPath CapabilityNo Yes CPU and Memory Efficiency Good Varies Forward OnlyYes No Read XMLYes Write XMLYesNoYes CRUDNo Yes