by robertskinner at 2013-03-15 07:54:08
I am new to using XML with PowerShell, so I am not sure why this occurs, it could be my limited understanding. However, when creating an XML file with XML Notepad, I was given the option of adding comments as a Child. The first example works, but not the second example. Is this a limitation of XML or how I handle it in PowerShell. I am assuming that since the data is not closed before the comment, this is a problem. Just curious as to why this is an option in the XML creater if it is bad practice to do this.
I am calling the xml file from a commandline and importing the values:
[xml]$xml=Get-Content -Path "$args"
$ftpdata = $xml.main.ftp.datapath
This works when I pull the data from the xml file
This does not work. The postion of the comment breaks this.
by ArtB0514 at 2013-03-15 08:14:09
It looks like the XML in your first example is invalid. It contains a second without a corresponding .
by robertskinner at 2013-03-15 08:26:34
That was a typo, I removed it. The first example is the one that does work.
by jonhtyler at 2013-03-15 09:32:51
For your second scenario, try this:
by robertskinner at 2013-03-15 10:55:04
That worked, thanks 🙂