I will use this sample data as an example:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>
Link to data: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)
Lets say I want to query the author and price
[xml]$XmlFileObj = Get-Content 'C:\Users\David\Documents\XmlSample.dtsx'
$XmlFileObj | Select-Xml -XPath "/catalog/book/author | /catalog/book/price " | Select-Object -ExpandProperty Node
The result is:
#text
-----
Gambardella, Matthew
44.95
Ralls, Kim
5.95
What if I want the result to look like:
#col1; col2
-----
Gambardella, Matthew; 44.95
Ralls, Kim ; 5.95
Or something like this in a table form...