I have an XML in the format:
<val:root>
<bla>
<value>1234</value>
</val:root>
I can do get-content of the file to an $xml variable, but I’m having trouble with the “val:root”.
Thanks for any help!
Edit:
I tried $xml.”val:root”, $xml.val, $xml.’val:root’ and $xml.{val:root}. Found the solution in Mizo’s answer:
$xml.root.value
Your XML file is missing a declaration for the
valnamespace. Also, the<bla>element is unterminated.Place a namespace declaration in the
<root>element:Then you can do
If you don’t have control over the XML data, you can declare the
valnamespace in a dummy root as a workaround:Then you can access the elements:
Replace
urn:dummywith a relevant identifier if you wish.