General Discussion

PSTK: Reading XML

tyrone_owen_1

Hope you can help.

So I've created a PowerShell script to pull back some volume information via the REST API and exported it to XML, here is a brief extract:

<?xml version="1.0"?>
-<Objs xmlns="http://schemas.microsoft.com/powershell/2004/04" Version="1.1.0.1">
  -<Obj RefId="0">
    -<TN RefId="0">
      <T>Selected.System.Management.Automation.PSCustomObject</T>
      <T>System.Management.Automation.PSCustomObject</T>
      <T>System.Object</T>
    </TN>
    -<MS>
      <S N="uuid">0058b9ad-5b3c-4871-bd68-b887430cf914</S>
      <S N="comment">Oracle DB</S>
      <S N="create_time">2018-12-04T17:26:37+00:00</S>
      <S N="name">oracle_data</S>
      <S N="style">flexvol</S>
      <B N="is_svm_root">false</B>
      <S N="type">rw</S>
        -<Obj RefId="1" N="aggregates">
          -<TN RefId="1">
            <T>System.Object[]</T>
            <T>System.Array</T>
            <T>System.Object</T>
          </TN>
          -<LST>
            -<Obj RefId="2">
              -<TN RefId="2">
                <T>System.Management.Automation.PSCustomObject</T>
                <T>System.Object</T>
              </TN>
              -<MS>
                <S N="name">n1_aggr_data01</S>
                <S N="uuid">1df78d34-9649-45ea-abf2-952ef11a0445</S>

 I've then imported the XML to a variable:

$xml = Get-Content xml.xml

I've then been trying to pull back content using this type of format, but without any luck:

$xml.root_node.child_node_type

1. How can I pull back the information for a single volume?

2. How can I pull back all of the volume names?

3. How can I pull back all the aggregate names that are listed within the XML?

4. Is there a better way to do what I'm trying to do?

 

Thanks in advance

0 REPLIES 0
Announcements
Register for Insight 2021 Digital

INSIGHT 2021 Digital: Meet the Specialists 2

On October 20-22, gear up for a fully digital, totally immersive virtual experience with a downright legendary lineup of world-renowned specialists. Tune in for visionary conversations, solution deep dives, technical sessions and more.

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public