Share this Page URL

Chapter 16. Working with XML Data in Access > Introducing XML - Pg. 566

Working with XML Data in Access 566 To add a record to this XML document, we would simply repeat the structure and change the data between the field tags: <Table> <Field1>Hello</Field1> <Field2>World</Field2> </Table> <Table> <Field1>XML is</Field1> <Field2>Amazing</Field2> </Table> An XML document can contain hundreds of records simply by repeating the structure and changing the data elements between the field tags. Because XML is structured in this way, importing data into and exporting data from Access is fairly straightforward. Constraining XML Data in Access It might be obvious from the preceding examples that data in a native XML document as compared to data in an Access database is largely unconstrained. That is, there seems to be nothing guiding which type of data a field can contain, whether or not a field is a key field, and whether or not a field can contain duplicate data and the like. For example, suppose we created the following XML docu- ment: <CampaignExpenses> <ExpenseID>Microsoft</ExpenseID> <CampaignID>Access</CampaignID> <ExpenseType>Rocks</ExpenseType> <AmountSpent<>/AmountSpent> <Description></Description> <DatePurchased></DatePurchased> <ApprovalRequired></ApprovalRequired>