zxing barcode generator example c# Mapping Schema Elements to Cells Using XPath in Visual C#.NET

Print Quick Response Code in Visual C#.NET Mapping Schema Elements to Cells Using XPath

Mapping Schema Elements to Cells Using XPath
QR Code JIS X 0510 Maker In Visual C#
Using Barcode printer for Visual Studio .NET Control to generate, create QR image in .NET applications.
www.OnBarcode.com
QR-Code Decoder In Visual C#
Using Barcode reader for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
After you have mapped a schema to a workbook, you need to map every element you want to appear in the worksheet to a range of cells so that you have a place for the associated XML data to reside. You don t need to assign every element in a schema to a cell or range; Excel will skip any unused elements when it imports the data from your XML file. You identify which element in a schema file to map to a cell using the XML Path language (XPath). Although the full XPath specification is long and involved, it boils down to a system of positively identifying the schema element to be mapped. In fact, XPath notation is very similar to the notation you use to identify the path of a Microsoft Windows file. For exam ple, the path of a file might be C:\ExcelProg\MySuppliers.xml, which indicates that the MySuppliers.xml file is in the ExcelProg directory on the C drive. The difference between the XPath language and the Windows file path notation system is that you need to specify the location of an element with a schema. As an example, consider the schema displayed in Figure 26-4 on page 547. The root element is named Root, which has the subelement Supplier, which in turn has the subelement SupplierID. The XPath notation for the SupplierID subelement is as follows:
Bar Code Generation In C#
Using Barcode creator for .NET Control to generate, create bar code image in VS .NET applications.
www.OnBarcode.com
Barcode Decoder In C#.NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
/Root/Supplier/SupplierID
Printing QR Code In .NET Framework
Using Barcode generation for ASP.NET Control to generate, create Quick Response Code image in ASP.NET applications.
www.OnBarcode.com
Making QR Code In VS .NET
Using Barcode creator for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in VS .NET applications.
www.OnBarcode.com
The Excel object model contains an XPath object with the properties and methods that Excel needs to use XPath data in its operations. Table 26-4 lists the XPath object s properties and methods.
Make QR Code JIS X 0510 In VB.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code JIS X 0510 image in .NET applications.
www.OnBarcode.com
Code 128A Maker In C#.NET
Using Barcode printer for .NET framework Control to generate, create Code 128 Code Set C image in .NET framework applications.
www.OnBarcode.com
Part 6: Excel and the Outside World: Collaborating Made Easy
2D Barcode Maker In C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Matrix Barcode image in .NET applications.
www.OnBarcode.com
Code 39 Extended Drawer In Visual C#.NET
Using Barcode creation for .NET Control to generate, create Code 39 image in .NET applications.
www.OnBarcode.com
26
Create European Article Number 13 In Visual C#.NET
Using Barcode creation for .NET Control to generate, create EAN13 image in VS .NET applications.
www.OnBarcode.com
ISSN - 13 Maker In Visual C#.NET
Using Barcode creation for Visual Studio .NET Control to generate, create ISSN image in .NET framework applications.
www.OnBarcode.com
Microsoft Office Excel 2003 Programming Inside Out
Drawing Linear Barcode In Visual Basic .NET
Using Barcode maker for .NET framework Control to generate, create Linear 1D Barcode image in .NET applications.
www.OnBarcode.com
GTIN - 13 Printer In Objective-C
Using Barcode printer for iPad Control to generate, create EAN 13 image in iPad applications.
www.OnBarcode.com
Table 26-4.
Creating EAN / UCC - 13 In None
Using Barcode generation for Microsoft Word Control to generate, create GS1 128 image in Microsoft Word applications.
www.OnBarcode.com
Printing Barcode In None
Using Barcode drawer for Word Control to generate, create bar code image in Office Word applications.
www.OnBarcode.com
The XPath Object s Properties and Methods
1D Barcode Drawer In Java
Using Barcode drawer for Java Control to generate, create Linear Barcode image in Java applications.
www.OnBarcode.com
Encoding UCC - 12 In Java
Using Barcode creation for BIRT Control to generate, create EAN / UCC - 13 image in Eclipse BIRT applications.
www.OnBarcode.com
Description
Make Universal Product Code Version A In None
Using Barcode maker for Online Control to generate, create UPC-A Supplement 2 image in Online applications.
www.OnBarcode.com
Encode Code 3 Of 9 In None
Using Barcode generator for Software Control to generate, create USS Code 39 image in Software applications.
www.OnBarcode.com
A read-only property that returns the XmlMap object that represents the schema assigned to the XPath object. A read-only Boolean value that returns True if the XPath object is assigned to a list, or returns False if the object is assigned to a single cell. Returns a string that represents the XPath for the object. Clears the schema mapping from the cell or cells mapped to the specified XPath. The Map argument (required) is an XmlMap variable representing the schema map into which you ll import your XML data; XPath (required) is a valid XPath statement; SelectionNamespace (an optional variant) specifies any namespace prefixes (you can leave this argument out if you put the full XPath in the XPath argument); Repeating (an optional Boolean) indicates whether the XPath object should be mapped to a single cell (False) or to a column in the list (True).
Name
Property Map Repeating
26
Value Method Clear SetValue(Map, XPath, SelectionNamespace, Repeating)
For more (and very technical) information on the XML Path language, visit the official XPath Web site at http://www.w3.org/TR/xpath.
The XPath object s SetValue method is the most important method in the bunch it lets you map a schema element directly to a cell or range. The following procedure defines the data file that contains the XML data, assigns the schema to be used in the SetValue method calls to the myMap object variable, and maps the elements to specific ranges. The result of the pro cedure is shown in Figure 26-7. Warning This procedure will only run correctly if you have previously mapped the MySuppliers.xsd schema to the active workbook. You can do so by running the ApplySchema procedure from the Mapping a Schema to a Worksheet Programmatically section found earlier in this chapter or by mapping the schema to your workbook manually.
Sub AssignElementsToRanges() Dim myMap As XmlMap Dim strXPath As String Dim strSelNS As String Dim xMapName As String Dim xDataFile As String
Part 6: Excel and the Outside World: Collaborating Made Easy
Excel and the Extensible Markup Language (XML)
On Error Resume Next xDataFile = C:\MySuppliers.xml" Set myMap = ActiveWorkbook.XmlMaps( Root_Map ) strXPath = /Root/Supplier/SupplierID" Range( B2:B10 ).XPath.SetValue myMap, strXPath Range( B2 ).Value = Supplier ID" strXPath = /Root/Supplier/CompanyName" Range( C2:C10 ).XPath.SetValue myMap, strXPath Range( C2 ).Value = Company Name" strXPath = /Root/Supplier/ContactName" Range( D2:D10 ).XPath.SetValue myMap, strXPath Range( D2 ).Value = Contact Name" strXPath = /Root/Supplier/ContactTitle" Range( E2:E10 ).XPath.SetValue myMap, strXPath Range( E2 ).Value = Contact Title" strXPath = /Root/Supplier/MailingAddress/Address" Range( F2:F10 ).XPath.SetValue myMap, strXPath Range( F2 ).Value = Address" strXPath = /Root/Supplier/MailingAddress/City" Range( G2:G10 ).XPath.SetValue myMap, strXPath Range( G2 ).Value = City" strXPath = /Root/Supplier/MailingAddress/Region" Range( H2:H10 ).XPath.SetValue myMap, strXPath Range( H2 ).Value = Region" strXPath = /Root/Supplier/MailingAddress/PostalCode" Range( I2:I10 ).XPath.SetValue myMap, strXPath Range( I2 ).Value = Postal Code" strXPath = /Root/Supplier/MailingAddress/Country" Range( J2:J10 ).XPath.SetValue myMap, strXPath Range( J2 ).Value = Country" strXPath = /Root/Supplier/Phone" Range( K2:K10 ).XPath.SetValue myMap, strXPath Range( K2 ).Value = Phone" strXPath = /Root/Supplier/Fax" Range( L2:L10 ).XPath.SetValue myMap, strXPath Range( L2 ).Value = Fax" ThisWorkbook.XmlMaps( Root_Map ).Import xDataFile If Err.Number = 0 Then MsgBox Data from & xDataFile & was imported into & _ the & xMapName & map." Else MsgBox There was a problem importing from & xDataFile Exit Sub End If End Sub
Copyright © OnBarcode.com . All rights reserved.