xml without name attribute

Welcome Forums General PowerShell Q&A xml without name attribute

Viewing 5 reply threads
  • Author
    Posts
    • #261608
      Participant
      Topics: 30
      Replies: 62
      Points: 184
      Rank: Participant

       

      i have a file where everything under “edgepolicies” is a unique name, but

      $xml.root.edgePolicies.ChildNodes

      returns the structure underneath the child nodes, without the names of the actual child nodes.

      i’d like an array with a name, level, source, and value column.

       

       

      • This topic was modified 2 weeks, 5 days ago by John Curtiss.
      • This topic was modified 2 weeks, 5 days ago by John Curtiss.
      • This topic was modified 2 weeks, 5 days ago by John Curtiss.
    • #261614
      Participant
      Topics: 30
      Replies: 62
      Points: 184
      Rank: Participant

       

    • #261626
      Participant
      Topics: 8
      Replies: 617
      Points: 2,393
      Helping Hand
      Rank: Community Hero

      You can use the hidden get_name() method.

      or

      Output

      You can view the hidden methods/properties by using Get-Member -Force

    • #261800
      Participant
      Topics: 30
      Replies: 62
      Points: 184
      Rank: Participant

      well thank heavens they hid it. 🙂

      bonus round: what if  some objects have more properties than just “level, source, value”, and i don’t necessarily know what those properties are ahead of time?

      nevermind on that one. $xml.root.edgePolicies.ChildNodes seems to show me everything.

      also: just for grins, is there a json version of get_name? my initial file was json, and about two frustrating hours after reading my first “but convertfrom-json is so easy!!” article, i figured ‘i’m at least familiar with working with xml, can i convert json to xml and go from there?…yes.’

      • This reply was modified 2 weeks, 4 days ago by John Curtiss.
    • #261824
      Participant
      Topics: 30
      Replies: 62
      Points: 184
      Rank: Participant

      here is a json sample. again i can get to $json.edgepolicies, but i don’t see any promising methods or properties in get-member -force here. all of my ‘nodes’ are listed as noteproperties.

       

      AllowDeletingBrowserHistory NoteProperty System.Management.Automation.PSCustomObject [email protected]{level=mandatory; scope=user; source=platform; value=False}
      AudioCaptureAllowedUrls NoteProperty System.Management.Automation.PSCustomObject [email protected]{level=mandatory; scope=user; source=platform; value=System.Object[]}

    • #262229
      Participant
      Topics: 16
      Replies: 1794
      Points: 3,300
      Helping Hand
      Rank: Community Hero
Viewing 5 reply threads
  • You must be logged in to reply to this topic.