General Discussion

PSTK: Reading XML

tyrone_owen_1
1,490 Views

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
Public