I am following along the example on how to parse XML with Powershell. I copied the contents of the example XML text and tried to parse with given commands. Everything worked OK.
Then I tried to parse my own XML file but immediately after I had issued [xml]$bar = Get-Content test2.xml command, I got the following error:
Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "The '=' character, hexadecimal value 0
x3D, cannot be included in a name. Line 5, position 19."
At line:1 char:1
+ [xml]$bar = Get-Content test2.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
+ FullyQualifiedErrorId : RuntimeException
So I suppose the mere fact that the contents of the XML file differ affects Powershell's ability to parse XML data?
My XML file contents:
<?xml version="1.0" encoding="UTF-8"?>
<metamarket id="lowvol">
<market id="asx" marketDir="creditcentraligaapaclve_asx_m" mandatoryNews="False">
<houseCode="CREDITBAAPACLVE" metahouseCode="CREDITBAAPACLVE"/>
</market>
<market id="bru" marketDir="creditcentraligaapaclve_bru_m" mandatoryNews="False">
<houseCode="CREDITBAAPACLVE" metahouseCode="CREDITBAAPACLVE"/>
</market>
<market id="sto" marketDir="creditcentraligaapaclve_sto_m" mandatoryNews="False">
<houseCode="CREDITBAAPACLVE" metahouseCode="CREDITBAAPACLVE"/>
</market>
</metamarket>