Converting from XML to CSV or Delimited

When converting from XML to CSV or delimited, the XML elements to convert to CSV are selected by an XPath expression.

After obtaining a list of elements that are described by the XPath expression, the node looks at the first element it encountered to determine the set of fields that will be included in the output CSV.

The node first examines the element to see if it contains child elements. If it does, then these child elements define the set of CSV fields. If it does not contain child elements, the node examines the element to see if it contains attributes. If it does, then these attributes define the set of CSV fields. This assumes that each element within the set of elements has the same set of child elements or attributes. If subsequent objects have more fields than the first node, these additional fields are ignored.

For example, either of these XML documents produce the save CSV as shown in the JSON example:

XML with child elements:
<addresses>
   <address>
	   <street>10 Main St</street>
	   <city>Smallville</city>
	   <state>GA</state>
	</address>
	<address>
	   <street>20 High St</street>
	   <city>Springville</city>
	   <zip>12345</zip>
	</address>
</addresses>
XML with attributes:
<addresses>
   <address street="10 Main St" city="Smallville" state="GA"/>
   <address street="20 High St" city="Springville" zip="12345"/>
</addresses>