Dealing with XML files

Importing CSV files is usually pretty straightforward. Comma separated data is very similar to a database table, with a header and then rows of information.

In contrast, XML files are typically hierarchical. To fit into a database table, ServiceNow uses XPath to find the data you want, then flattening anything in that node.

Consider the following XML file that contains a list of hotel rooms. It is also hosted at http://www.gardiner-hotels.com/import/hotelrooms.xml

<xml> 
  <produced_on>2016-07-01</produced_on> 
  <room> 
    <number>123</number> 
    <location> 
      <corridor>A5</corridor> 
      <floor>1</floor> 
    </location> 
  </room> 
  <room> 
    <number>124</number> 
    <location> 
      <corridor>A5</corridor> 
      <floor>1</floor> 
    </location> 
  </room> 
</xml> 

An XPath ...

Get ServiceNow: Building Powerful Workflows now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.