[ Team LiB ] |
Recipe 18.1 Import XML Structured as Elements18.1.1 ProblemYou need to import simple XML data into a new table. 18.1.2 SolutionYou can import XML into a new table from the File menu when the Tables category is selected in the Objects pane by following these steps:
Figure 18-2. Viewing the structure of an XML file when importing into Access
A new table named Car has been created. 18.1.3 DiscussionWhen importing an XML file that has the structure Access expects, containing a hierarchical set of nested elements, the table name is derived from the first element after the root, in this case Car. The Make, Model and Price elements become columns in the table. The source XML file looks like this: <?xml version="1.0" encoding="UTF-8" ?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata"> <Car> <Make>Mini Cooper</Make> <Model>S</Model> <Price>20,000</Price> </Car> <Car> <Make>Lexus</Make> <Model>LS430</Model> <Price>60,000</Price> </Car> <Car> <Make>Porsche</Make> <Model>Boxter</Model> <Price>43,000</Price> </Car> <Car> <Make>Ford</Make> <Model>Mustang</Model> <Price>25,000</Price> </Car> <Car> <Make>Toyota</Make> <Model>Camry</Model> <Price>20,000</Price> </Car> </dataroot> When you open the Car table in Datasheet view, it looks like Figure 18-3, with the data organized by column (element), with each row representing a single Car element in the XML file. Figure 18-3. The Car table in Datasheet view
18.1.4 See AlsoThe following MSDN article gives a good explanation of XML namespaces: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml05202002.asp?frame=true |
[ Team LiB ] |