I have an XML in powershell below:
[Xml]$MyXmlVariable = @"
<Mylist>
<Item Number="1">
<Name>"AMD Ryzen 5 3600x"</Name>
<Type>"CPU"</Type>
<Price>"$169.99"</Price>
<Where>"Amazon"</Where>
<Other>
<ThreadCount>"12"</ThreadCount>
<Cores>"6"</Cores>
</Other>
</Item>
</MyList>
"@
And it looks fne to me, but when I try to define it, I get the error
Cannot convert value "<Mylist>
<Item Number="1">
<Name>"AMD Ryzen 5 3600x"</Name>
<Type>"CPU"</Type>
<Price>".99"</Price>
<Where>"Amazon"</Where>
<Other>
<ThreadCount>"12"</ThreadCount>
<Cores>"6"</Cores>
</Other>
</Item>
</MyList>" to type "System.Xml.XmlDocument". Error: "The 'Mylist' start tag on line 1
position 2 does not match the end tag of 'MyList'. Line 12, position 3."
At line:1 char:1
+ [Xml]$MyXmlVariable = @"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataExcepti
on
+ FullyQualifiedErrorId : RuntimeException
AFAIK there doesn't seem to be an error but Powershell says otherwise. Please Help
MyListandMylistare different so that is where the error comes from. See stackoverflow.com/questions/35220463/…<Mylist>to<MyList>it works :P. Sorry for the stupid question... One more thing, if I have multiple items and I want the item where theNumbervalue is equal to 1 what would I do??/Where-Object,$MyXmlVariable.MyList.Item | ? {$_.Number -eq 1}you could do this with other values too,$MyXmlVariable.MyList.Item | ? {$_.Type -eq "CPU"}$169.99will not show because$expands to variables in powershell so use$$169.99,"`$169.99"or'$169.99'