Creating Your Own XSD : Excel XML « Excel « VBA / Excel / Access / Word






Creating Your Own XSD

 
     Sub Create_XSD()
         Dim StrMyXml As String, MyMap As XmlMap
         Dim StrMySchema As String
         StrMyXml = "<EmployeeSales>"
         StrMyXml = StrMyXml & "<Employee>"
         StrMyXml = StrMyXml & "<Empid>999</Empid>"
         StrMyXml = StrMyXml & "<FirstName>Text</FirstName>"
         StrMyXml = StrMyXml & "<LastName>Text</LastName>"
         StrMyXml = StrMyXml & "<InvoiceNumber>999</InvoiceNumber>"
         StrMyXml = StrMyXml & "<InvoiceAmount>999</InvoiceAmount>"
         StrMyXml = StrMyXml & "</Employee>"
         StrMyXml = StrMyXml & "<Employee></Employee>"
         StrMyXml = StrMyXml & "</EmployeeSales>"

         Application.DisplayAlerts = False
         Set MyMap = ThisWorkbook.XmlMaps.add(StrMyXml)
         Application.DisplayAlerts = True

         StrMySchema = ThisWorkbook.XmlMaps(1).Schemas(1).XML
           Open "C:\StrMySchema.xsd" For Output As #1
           Print #1, StrMySchema
           Close #1
     End Sub

 








Related examples in the same category

1.Get Schema
2.returns a workbook object with the XML data mapped to your spreadsheet:
3.Programmatically Changing XML Map Properties
4.Refresh Your XML Data
5.Importing Data into an Existing XML Map
6.Exporting to an XML File
7.Leveraging DOM and XPath to Manipulate XML Files
8.Using DOM with ADO to Convert Excel Data to XML
9.Compatibility Mode
10.XML transform
11.Export to XML file