How do I get a list of child nodes from XML

Question:

Given the following sample script (saved as sample.txt on my hard drive):

I want to extract the XML and determine if any child nodes have been added to node book. For this use case, assume that author is the new node.

I have written a script that works, but it seems grossly inefficient:

Is there a better way to populate *$found_fields* rather than creating a CSV file, storing the first row in a variable and then deleting the CSV file?

Answer:

Try changing your -Expand from Node to Name (and Where-Object to exclude title and price)

This will give you any unexpected child nodes of book.

Source:

How do I get a list of child nodes from XML by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply