XML Support in Visual Basic 9.0 - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

XML Support in Visual Basic 9.0

Description:

street 8 Oak Avenue /street city Old Town /city state PA ... ASP.Net style holes (anywhere XLINQ allows expression) Short end-tags. Offside layout rule ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 11
Provided by: erik223
Category:
Tags: xml | basic | support | visual

less

Transcript and Presenter's Notes

Title: XML Support in Visual Basic 9.0


1
XML Support in Visual Basic 9.0
2
A Simple Exercise
ltpurchaseOrder orderDate"1999-10-20"gt ltshipTo
country"US"gt ltnamegtAlice Smithlt/namegt
ltstreetgt123 Maple Streetlt/streetgt ltcitygtMill
Valleylt/citygt ltstategtCAlt/stategt
ltzipgt90952lt/zipgt lt/shipTogt ltbillTo
country"US"gt ltnamegtRobert Smithlt/namegt
ltstreetgt8 Oak Avenuelt/streetgt ltcitygtOld
Townlt/citygt ltstategtPAlt/stategt
ltzipgt95819lt/zipgt lt/billTogt ltitemsgt ltitem
partNum"872-AA"gt ltproductNamegtLawnmowerlt/pr
oductNamegt ltquantitygt1lt/quantitygt
ltpricegt148.95lt/pricegt lt/itemgt ltitem
partNum"926-AA"gt ltproductNamegtBaby
Monitorlt/productNamegt ltquantitygt1lt/quantitygt
ltpricegt39.98lt/pricegt
ltshipDategt1999-05-21lt/shipDategt lt/itemgt
lt/itemsgt lt/purchaseOrdergt
  • Create the document
  • Print it!
  • Compute total price
  • Add new child

3
XLINQ Key Design Points
  • Smaller, Faster
  • Document Free
  • Functional Construction
  • Uniform Axis
  • Easy to Extract Values
  • XML Name Simplification

4
Object Model
XName
XAttribute
XNode
XCData
XComment
XContainer
XDeclaration
XDocumentType
XProcessing Instruction
XDocument
XElement
No Text Node
5
XML In VB 9
Better, but not yet good enough
Function Total(PO As XElement) As Double For
Each Dim Item In PO.Descendants("item") Dim
Price As Double Item.Element("price") Dim
Quantity As Integer Item.Element("quantity")
Total QuantityPrice Next End Function
PO.Add(New XElement("Total", _ New
XAttribute("Price", Total(PO))))
Too many strings, interpretative code.
Does not look like XML
6
XML Literals
Dim PO _ltpurchaseOrder orderDate"1999-10-20"gt
ltshipTo country"US"gt ltnamegtAlice
Smithlt/namegt ltstreetgt123 Maple
Streetlt/streetgt ltcitygtMill Valleylt/citygt
ltstategtCAlt/stategt ltzipgt90952lt/zipgt
lt/shipTogt ltbillTo country"US"gt
ltnamegtRobert Smithlt/namegt ltstreetgt8 Oak
Avenuelt/streetgt ltcitygtOld Townlt/citygt
ltstategtPAlt/stategt ltzipgt95819lt/zipgt
lt/billTogt ltitemsgt ltitem partNum"872-AA"gt
ltproductNamegtLawnmowerlt/productNamegt
ltquantitygt1lt/quantitygt ltpricegt148.95lt/pricegt
lt/itemgt ltitem partNum"926-AA"gt
ltproductNamegtBaby Monitorlt/productNamegt
ltquantitygt1lt/quantitygt ltpricegt39.98lt/pricegt
ltshipDategt1999-05-21lt/shipDategt
lt/itemgt lt/itemsgt lt/purchaseOrdergt
CutPaste XML
7
XML Literals
Dim ShipTo _ ltshipTo country"US"gt
ltnamegtAlice Smithlt/namegt ltstreetgt123 Maple
Streetlt/streetgt ltcitygtMill Valleylt/citygt
ltstategtCAlt/stategt ltzipgt90952lt/zipgt
lt/shipTogtDim ShipTo ltbillTo
country"US"gtlt/billTogt Dim ShipTo
ltitemsgtlt/itemsgt Dim PO _
ltpurchaseOrder orderDatelt System.DateTime.Today
gtgt lt ShipTo gtlt BillTo gtlt
Items gt lt/gt
CutPaste XML
ASP.Net style holes (anywhere XLINQ allows
expression)
Compiled to imperative construction!
Short end-tags
Offside layout rule
8
Easier Namespaces
Dim ShipTo _ ltshipTo xmlns""
country"US"gt ltnamegtAlice Smithlt/namegt
ltstreetgt123 Maple Streetlt/streetgt
ltprefixcity xmlnsprefix""gt Mill
Valley lt/prefixcitygt ltstategtCAlt/stategt
ltzipgt90952lt/zipgt lt/shipTogt
9
Axis Members
x As XElement/IEnumerable(Of XElement)x.m ?
x.Elements("m")x._at_m ? x.Attribute("m")x...m ?
x.Descendants("m")
Function Total(PO As XElement) As Double For
Each Dim Item In PO...item Dim Price As
Double Item.price Dim Quantity As Integer
Item.quantity Total QuantityPrice
Next End Function Function Total(PO As XElement)
As Double Return Select Sum(QuantityPrice)
From PO...item End Function
10
Conclusions
  • New modern, redesigned XML API
  • Easier, lighter DOM
  • XQuery expressiveness
  • Cross data-model queries via LINQ
  • XML is first class citizen in VB9

http//msdn.microsoft.com/netframework/future/linq
/http//msdn.microsoft.com/vbasic/future/default.
aspx
Write a Comment
User Comments (0)
About PowerShow.com