I have this following XML that I need to read the attributes dynamically however I am stuck in finding the correct way to do it in PS:
<DataGroups>
<Category1 Identifier="Project789">
<Category2 Identifier="Project234">
<SimpleCategory56 Identifier="Project56">
......
</DataGroups>
I have tried the following till now which works however how do I do this dynamically??
$xml = [xml](get-content $Path)
$test = $xml.DataGroups.Category1.Identifier
I have also tried doing something this:
$xml = [xml](get-content $Path)
Select-Xml -Xml $xml -XPath "//Category1/@Identifier"
but then I am getting somwthing cryptic like the following:
Node Path Pattern
---- ---- -------
Identifier InputStream //Category1/@Identifier
You were on the right track. You had to simply try this in the Select-Xml
:
$xml = [xml](get-content $Path)
(Select-Xml -Xml $xml -XPath "//./@Identifier").Node.Value
Please try and let me know. It should return
Project789
Project234
Project56
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.