SlideShare a Scribd company logo
Linq To XML Overview
Dale Hawthorne
For Sherwin Williams
Linq To XML Overview -2
Previous .NET Options:
• XmlDocument: Implements DOM, processor
and memory intensive due to recursion,
loading entire document in a tree before
proceeding
• XmlReader, XmlWriter, XslCompiledTransform,
XmlNamespaceManager: Fast but code
implementations are difficult to understand,
not very readable
Linq To XML Overview -3
Advantages of Linq To XML:
• Built over XMLWriters and XMLReaders, will
generally be faster than XmlDocument class
• Uses Linq query syntax, so processing XML more
like asking or answering a question than parsing a
document
• Works with existing XML Schemas (.XSD), XML
Transforms (XSLT), XML Annotations, .NET XML
classes such as XmlReader, XPathNavigator
• Simpler classes: XDocument, XElement,
XAttribute, XCData, XComment
Linq To XML Overview - 4
How to use:
• Be sure that the Visual Studio project targets
the 3.5 (or above) framework.
• Add a reference to System.Linq.Dll
• Add using or imports statements for
System.Linq and System.Xml.Linq
• Be sure to catch System.Xml.XmlException or
other exceptions for malformed and invalid
XML
Linq To XML Overview - 5
Demos:
1. Loading XML from a file (C# and VB)
2. Loading XML from a string literal
3. Creating an XML tree in C#
4. Creating an XML Document with multiple
namespaces
5. Querying an XML document with namepaces
6. XML Document Validation
7. XSL Document Transformation
Linq To XML Overview - 6
XML Goodies in Visual Studio, SDK
• XSD.EXE can generate .NET classes from XSD
• SVCUTIL.EXE can generate WCF DataContracts and
services from XSD
• Visual Studio allows XSLT compilation and debugging.
• Linq To XSD:
(http://www.hanselman.com/blog/LINQToEverything
LINQToXSDAddsMoreLINQiness.aspx,http://linqtoxsd.
codeplex.com/,
http://www.netframeworkdev.com/net-base-class-
library/linq-to-xsd-how-to-use-linq-to-xsd-
functionality-in-general-application-2782.shtml,
http://aspalliance.com/chapters/chapters/184719254
8/linq%20-%20sample%20chapter.pdf)
Linq To XML Overview - Final Links
Links on XML, LINQ to XML
• O’Reilly XML Site: http://www.xml.com/
• ZVON.org: http://www.zvon.org/index.php
• W3Schools.com: http://www.w3schools.com/xml/default.asp
• XML Pitstop: http://www.xmlpitstop.com/
• LINQ on MSDN: http://msdn.microsoft.com/en-
us/library/bb397926.aspx
• LINQ to XML on MSDN: http://msdn.microsoft.com/en-
us/library/bb387098.aspx
• Get Started with LINQ to XML: http://www.asp.net/learn/linq-
videos/video-215.aspx
• Enable XML IntelliSense and Use XML Namespaces
http://www.asp.net/learn/linq-videos/video-216.aspx
• Create Excel Spreadsheets using LINQ to XML
http://www.asp.net/learn/linq-videos/video-218.aspx

More Related Content

What's hot

Collector Web Services
Collector Web ServicesCollector Web Services
Collector Web Services
publisyst
 
Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?
Ali LeClerc
 
Linux17 MySQL_installation
Linux17 MySQL_installationLinux17 MySQL_installation
Linux17 MySQL_installation
Jainul Musani
 
Ndb cluster 80_requirements
Ndb cluster 80_requirementsNdb cluster 80_requirements
Ndb cluster 80_requirements
mikaelronstrom
 
Introducing Apache Jackrabbit OAK
Introducing Apache Jackrabbit OAKIntroducing Apache Jackrabbit OAK
Introducing Apache Jackrabbit OAK
Yash Mody
 
Ambry : Linkedin's Scalable Geo-Distributed Object Store
Ambry : Linkedin's Scalable Geo-Distributed Object StoreAmbry : Linkedin's Scalable Geo-Distributed Object Store
Ambry : Linkedin's Scalable Geo-Distributed Object Store
Sivabalan Narayanan
 
Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012
Piergiorgio Lucidi
 
LNUG - A year with AWS
LNUG - A year with AWSLNUG - A year with AWS
LNUG - A year with AWS
Andrew Clarke
 
What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3
Pavan Deolasee
 
File System On Steroids
File System On SteroidsFile System On Steroids
File System On Steroids
Jukka Zitting
 
Ndb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_memNdb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_mem
mikaelronstrom
 
Using database object relational storage
Using database object relational storageUsing database object relational storage
Using database object relational storage
Dalibor Blazevic
 
WiredTiger MongoDB Integration
WiredTiger MongoDB Integration WiredTiger MongoDB Integration
WiredTiger MongoDB Integration
MongoDB
 
Mongo db3.0 wired_tiger_storage_engine
Mongo db3.0 wired_tiger_storage_engineMongo db3.0 wired_tiger_storage_engine
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
Introducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongoIntroducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongo
Yash Mody
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
sqlserver.co.il
 
mogpres
mogpresmogpres
mogpres
Hiroshi Ono
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developer
UC San Diego
 
Mime Magic With Apache Tika
Mime Magic With Apache TikaMime Magic With Apache Tika
Mime Magic With Apache Tika
Jukka Zitting
 
2016 jan-pugs-meetup-v9.5-features
2016 jan-pugs-meetup-v9.5-features2016 jan-pugs-meetup-v9.5-features
2016 jan-pugs-meetup-v9.5-features
Sameer Kumar
 

What's hot (20)

Collector Web Services
Collector Web ServicesCollector Web Services
Collector Web Services
 
Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?Level 101 for Presto: What is PrestoDB?
Level 101 for Presto: What is PrestoDB?
 
Linux17 MySQL_installation
Linux17 MySQL_installationLinux17 MySQL_installation
Linux17 MySQL_installation
 
Ndb cluster 80_requirements
Ndb cluster 80_requirementsNdb cluster 80_requirements
Ndb cluster 80_requirements
 
Introducing Apache Jackrabbit OAK
Introducing Apache Jackrabbit OAKIntroducing Apache Jackrabbit OAK
Introducing Apache Jackrabbit OAK
 
Ambry : Linkedin's Scalable Geo-Distributed Object Store
Ambry : Linkedin's Scalable Geo-Distributed Object StoreAmbry : Linkedin's Scalable Geo-Distributed Object Store
Ambry : Linkedin's Scalable Geo-Distributed Object Store
 
Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012Apache ManifoldCF @ Linux Day 2012
Apache ManifoldCF @ Linux Day 2012
 
LNUG - A year with AWS
LNUG - A year with AWSLNUG - A year with AWS
LNUG - A year with AWS
 
What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3
 
File System On Steroids
File System On SteroidsFile System On Steroids
File System On Steroids
 
Ndb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_memNdb cluster 80_ycsb_mem
Ndb cluster 80_ycsb_mem
 
Using database object relational storage
Using database object relational storageUsing database object relational storage
Using database object relational storage
 
WiredTiger MongoDB Integration
WiredTiger MongoDB Integration WiredTiger MongoDB Integration
WiredTiger MongoDB Integration
 
Mongo db3.0 wired_tiger_storage_engine
Mongo db3.0 wired_tiger_storage_engineMongo db3.0 wired_tiger_storage_engine
Mongo db3.0 wired_tiger_storage_engine
 
Introducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongoIntroducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongo
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
 
mogpres
mogpresmogpres
mogpres
 
Basic terminologies for a developer
Basic terminologies for a developerBasic terminologies for a developer
Basic terminologies for a developer
 
Mime Magic With Apache Tika
Mime Magic With Apache TikaMime Magic With Apache Tika
Mime Magic With Apache Tika
 
2016 jan-pugs-meetup-v9.5-features
2016 jan-pugs-meetup-v9.5-features2016 jan-pugs-meetup-v9.5-features
2016 jan-pugs-meetup-v9.5-features
 

Similar to Linq To XML Overview

Linq to xml
Linq to xmlLinq to xml
Linq to xml
Mickey
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
GlobalLogic Ukraine
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
Marcelo Ochoa
 
XML Pipelines
XML PipelinesXML Pipelines
XML Pipelines
Stylus Studio
 
Working with xml data
Working with xml dataWorking with xml data
Working with xml data
aspnet123
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
Ulrich Krause
 
LINQ to XML
LINQ to XMLLINQ to XML
LINQ to XML
ukdpe
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
Antonio García-Domínguez
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
Ulrich Krause
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
Prashant Rane
 
Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2
asim78
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
Karen Benoit
 
Lotus Domino 8.5
Lotus Domino 8.5Lotus Domino 8.5
Lotus Domino 8.5
Lalit Sharma
 
Cetpa dotnet taining
Cetpa dotnet tainingCetpa dotnet taining
Cetpa dotnet taining
sharmamohan13989
 
epicenter2010 Open Xml
epicenter2010   Open Xmlepicenter2010   Open Xml
epicenter2010 Open Xml
Craig Murphy
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
Hicham QAISSI
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
Ulrich Krause
 
Nzitf Velociraptor Workshop
Nzitf Velociraptor WorkshopNzitf Velociraptor Workshop
Nzitf Velociraptor Workshop
Velocidex Enterprises
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
Frank Munz
 

Similar to Linq To XML Overview (20)

Linq to xml
Linq to xmlLinq to xml
Linq to xml
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
 
XML Pipelines
XML PipelinesXML Pipelines
XML Pipelines
 
Working with xml data
Working with xml dataWorking with xml data
Working with xml data
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
 
LINQ to XML
LINQ to XMLLINQ to XML
LINQ to XML
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
 
Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2Asp.Net 3.5 Part 2
Asp.Net 3.5 Part 2
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
Lotus Domino 8.5
Lotus Domino 8.5Lotus Domino 8.5
Lotus Domino 8.5
 
Cetpa dotnet taining
Cetpa dotnet tainingCetpa dotnet taining
Cetpa dotnet taining
 
epicenter2010 Open Xml
epicenter2010   Open Xmlepicenter2010   Open Xml
epicenter2010 Open Xml
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
 
Nzitf Velociraptor Workshop
Nzitf Velociraptor WorkshopNzitf Velociraptor Workshop
Nzitf Velociraptor Workshop
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 

Linq To XML Overview

  • 1. Linq To XML Overview Dale Hawthorne For Sherwin Williams
  • 2. Linq To XML Overview -2 Previous .NET Options: • XmlDocument: Implements DOM, processor and memory intensive due to recursion, loading entire document in a tree before proceeding • XmlReader, XmlWriter, XslCompiledTransform, XmlNamespaceManager: Fast but code implementations are difficult to understand, not very readable
  • 3. Linq To XML Overview -3 Advantages of Linq To XML: • Built over XMLWriters and XMLReaders, will generally be faster than XmlDocument class • Uses Linq query syntax, so processing XML more like asking or answering a question than parsing a document • Works with existing XML Schemas (.XSD), XML Transforms (XSLT), XML Annotations, .NET XML classes such as XmlReader, XPathNavigator • Simpler classes: XDocument, XElement, XAttribute, XCData, XComment
  • 4. Linq To XML Overview - 4 How to use: • Be sure that the Visual Studio project targets the 3.5 (or above) framework. • Add a reference to System.Linq.Dll • Add using or imports statements for System.Linq and System.Xml.Linq • Be sure to catch System.Xml.XmlException or other exceptions for malformed and invalid XML
  • 5. Linq To XML Overview - 5 Demos: 1. Loading XML from a file (C# and VB) 2. Loading XML from a string literal 3. Creating an XML tree in C# 4. Creating an XML Document with multiple namespaces 5. Querying an XML document with namepaces 6. XML Document Validation 7. XSL Document Transformation
  • 6. Linq To XML Overview - 6 XML Goodies in Visual Studio, SDK • XSD.EXE can generate .NET classes from XSD • SVCUTIL.EXE can generate WCF DataContracts and services from XSD • Visual Studio allows XSLT compilation and debugging. • Linq To XSD: (http://www.hanselman.com/blog/LINQToEverything LINQToXSDAddsMoreLINQiness.aspx,http://linqtoxsd. codeplex.com/, http://www.netframeworkdev.com/net-base-class- library/linq-to-xsd-how-to-use-linq-to-xsd- functionality-in-general-application-2782.shtml, http://aspalliance.com/chapters/chapters/184719254 8/linq%20-%20sample%20chapter.pdf)
  • 7. Linq To XML Overview - Final Links Links on XML, LINQ to XML • O’Reilly XML Site: http://www.xml.com/ • ZVON.org: http://www.zvon.org/index.php • W3Schools.com: http://www.w3schools.com/xml/default.asp • XML Pitstop: http://www.xmlpitstop.com/ • LINQ on MSDN: http://msdn.microsoft.com/en- us/library/bb397926.aspx • LINQ to XML on MSDN: http://msdn.microsoft.com/en- us/library/bb387098.aspx • Get Started with LINQ to XML: http://www.asp.net/learn/linq- videos/video-215.aspx • Enable XML IntelliSense and Use XML Namespaces http://www.asp.net/learn/linq-videos/video-216.aspx • Create Excel Spreadsheets using LINQ to XML http://www.asp.net/learn/linq-videos/video-218.aspx