locked
Attempt at reading an XML RRS feed

  • Question

  • Got the following XML output -- https://pastebin.com/dak1hGfT

    From RestAPI of VMWare App Volumes Server, goal is to read just the Application names from it.

    Have had some limited luck with

    [xml]$XmlDocument = Get-Content -Path C:\Users\asenn\Desktop\test.xml

    $XmlDocument.Objs.Obj.MS.Obj.LST.Obj.MS.S.N.Item(0)

    That gives me the first App Name, but is in a format of

    N    #text                 
    -    -----                 
    name Haskell Platform 8.0.1

    My goal is to get just those names, and nothing else.  That first was somewhat easy as 0, but the names are not in a specific spot each time, and having some trouble figuring out best way to get the info needed with Powershell.

    Any assistance would be greatly appreciated.  Attempting to parse apps that are in an app volume for a script I am working on.

    Thanks

    Wednesday, December 20, 2017 8:23 PM

Answers

  • This would be much easier:

    $haskell = Import-CliXml d:\test\dak1hGfT.txt
    $haskell.applications|Select id,name,version,Guid


    \_(ツ)_/

    • Marked as answer by apsenn Wednesday, December 20, 2017 8:48 PM
    Wednesday, December 20, 2017 8:43 PM

All replies

  • $XmlDocument.Objs.Obj.MS.Obj.LST.Obj.MS.S[0].'#text'


    \_(ツ)_/

    Wednesday, December 20, 2017 8:35 PM
  • Thanks, that does give just the name, is there an easy way to find the names of each.  As mentioned the index number where that was 0 doesn't seem to follow a sure flow, and as some volumes might have more apps that would throw it off.

    Was hoping for a way to just find every section with name in it and get that text, but still hunting.

    Thanks

    Wednesday, December 20, 2017 8:38 PM
  • $xml.Objs.Obj.MS.Obj.LST.Obj.MS.S | ForEach{$_.N}

    \_(ツ)_/

    Wednesday, December 20, 2017 8:41 PM
  • This would be much easier:

    $haskell = Import-CliXml d:\test\dak1hGfT.txt
    $haskell.applications|Select id,name,version,Guid


    \_(ツ)_/

    • Marked as answer by apsenn Wednesday, December 20, 2017 8:48 PM
    Wednesday, December 20, 2017 8:43 PM
  • This would be much easier:

    $haskell = Import-CliXml d:\test\dak1hGfT.txt
    $haskell.applications|Select id,name,version,Guid


    \_(ツ)_/

    Thanks very much, that method is much easier and gives me exactly what I am looking for output wise.

    • Proposed as answer by ben horn Thursday, December 21, 2017 12:37 AM
    • Unproposed as answer by ben horn Thursday, December 21, 2017 12:37 AM
    • Proposed as answer by ben horn Thursday, December 21, 2017 12:42 AM
    • Unproposed as answer by jrv Thursday, December 21, 2017 12:44 AM
    Wednesday, December 20, 2017 8:48 PM