how add/update Element with same name as other

Welcome Forums General PowerShell Q&A how add/update Element with same name as other

Viewing 2 reply threads
  • Author
    Posts
    • #243971
      Participant
      Topics: 11
      Replies: 15
      Points: 104
      Rank: Participant

      I have xml file with following data.

      <actor>
      <name>Actor Name 1</name>
      <type>Actor</type>
      <thumb>image.jpg</thumb>
      </actor>

      <actor>
      <name>Actor Name 2</name>
      <type>Actor</type>
      <thumb>image.jpg</thumb>
      </actor>

      <genre>genre1</genre>
      <genre>genre2</genre>

       

      I would like to compare existing genre and actors in xml file with value i have to see if they already exited if not add/remove/update them.

      If I do update the actor name then i would like to remove the image of the actor from the xml

      $file = New-Object System.Xml.XmlDocument
      $file.Load($file_path)

      $file_data.genre

      $file_data.actor.name

      but i dont know how to compare or update date in nested element

    • #243998
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      Hi Lalajee,

      Your post is quite vague and I’m not sure what you’re trying to accomplish. Hopefully this example will help. Otherwise, please add more details. 🙂

    • #244049
      Participant
      Topics: 11
      Replies: 15
      Points: 104
      Rank: Participant

      What i want to do is check the actors in my xml file and company then with new actors which in arary to say if actors already in xml or not if not then add them but if the actor existed in xml but not in arrary then remove them from xml

      Same thing for genre

Viewing 2 reply threads
  • You must be logged in to reply to this topic.