Manage xml with pwsh

hello , i have recently find a new way of manage the xml
which using foreach adding the all kind of member into new psobject and we will get something like this

after this we could use add-member and change the value of the member to mange the XML

convert back to xml upload your xml to the web after changing

for now i could do something like this

Please do not post images of code or sample data. Instead post the plain text and format it as code.

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

What is your question?

1 Like
5-toubun no Hanayome ?                                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Akagami no Shirayuki-hime                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Akame ga Kill!                                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Amagi Brilliant Park                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Angel Beats!                                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Ano Hi Mita Hana no Namae wo Bokutachi wa Mada Shiranai.                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Ansatsu Kyoushitsu                                                                                           : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Arakawa Under the Bridge                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Aria the Animation                                                                                           : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Baka to Test to Shoukanjuu                                                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Bakemonogatari                                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Black Bullet                                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Bocchi the Rock!                                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Boku dake ga Inai Machi                                                                                      : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Charlotte                                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Charlotte: Tsuyoimono-tachi                                                                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, Special]…}
Clannad: After Story                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Code Geass: Hangyaku no Lelouch                                                                              : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Cyberpunk: Edgerunners                                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, ONA]…}
Dagashi Kashi                                                                                                : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Denpa Onna to Seishun Otoko                                                                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Do It Yourself!!                                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Dokyuu Hentai HxEros                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Fate/stay night                                                                                              : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Fullmetal Alchemist: Brotherhood                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Gakusen Toshi Asterisk                                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Gintama'                                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Grand Blue                                                                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Hidan no Aria                                                                                                : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Honzuki no Gekokujou: Shisho ni Naru Tame ni wa Shudan wo Erandeiraremasen                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Houkago Teibou Nisshi                                                                                        : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Inou-Battle wa Nichijou-kei no Naka de                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Itai no wa Iya nanode Bougyoryoku ni Kyokufuri Shitai to Omoimasu. 2                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Jashin-chan Dropkick'                                                                                        : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
K-On!                                                                                                        : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kage no Jitsuryokusha ni Naritakute! 2nd Season                                                              : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kaguya-sama wa Kokurasetai: Tensai-tachi no Renai Zunousen                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kaguya-sama wa Kokurasetai? Tensai-tachi no Renai Zunousen                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kamisama no Memochou                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kanojo mo Kanojo Season 2                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kanojo, Okarishimasu                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kawaii dake ja Nai Shikimori-san                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kimi no Suizou wo Tabetai                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, Movie]…}
Kishuku Gakkou no Juliet                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Koi wa Sekai Seifuku no Ato de                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kono Bijutsu-bu ni wa Mondai ga Aru!                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kono Oto Tomare!                                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kono Subarashii Sekai ni Shukufuku wo!                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Kyokou Suiri Season 2                                                                                        : {[my_id, 0], [my_watched_episodes, 0], [my_status, Plan to Watch], [series_type, TV]…}
Liar Liar                                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Plan to Watch], [series_type, TV]…}
Little Witch Academia (TV)                                                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Lycoris Recoil                                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Machikado Mazoku                                                                                             : {[my_id, 0], [my_watched_episodes, 12], [my_status, Completed], [series_type, TV]…}
Machikado Mazoku: 2-choume                                                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Machine-Doll wa Kizutsukanai                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Mahouka Koukou no Rettousei                                                                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Majo no Tabitabi                                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Maou Gakuin no Futekigousha: Shijou Saikyou no Maou no Shiso, Tensei shite Shison-tachi no Gakkou e Kayou II : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Masamune-kun no Revenge                                                                                      : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Mashiro-iro Symphony: The Color of Lovers                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Mushishi                                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
NieR:Automata Ver1.1a                                                                                        : {[my_id, 0], [my_watched_episodes, 0], [my_status, Plan to Watch], [series_type, TV]…}
No Game No Life                                                                                              : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Non Non Biyori                                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Non Non Biyori Movie: Vacation                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, Movie]…}
Non Non Biyori Repeat: Hotaru ga Tanoshinda                                                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, OVA]…}
Noragami                                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Nourin                                                                                                       : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Oni Chichi: Re-born                                                                                          : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, OVA]…}
Oniichan wa Oshimai!                                                                                         : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Ore no Nounai Sentakushi ga, Gakuen Love Comedy wo Zenryoku de Jama Shiteiru                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Pandora Hearts                                                                                               : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Plastic Memories                                                                                             : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Rakudai Kishi no Cavalry                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Rokujouma no Shinryakusha!?                                                                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Ryuuou no Oshigoto!                                                                                          : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Saijaku Muhai no Bahamut                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Satsuriku no Tenshi                                                                                          : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Seitokai no Ichizon Lv.2                                                                                     : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, ONA]…}
Shakugan no Shana                                                                                            : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Shigatsu wa Kimi no Uso                                                                                      : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Shingeki no Bahamut: Genesis                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Shuumatsu Nani Shitemasu ka? Isogashii desu ka? Sukutte Moratte Ii desu ka?                                  : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Slow Loop                                                                                                    : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Soredemo Ayumu wa Yosetekuru                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Sousei no Onmyouji                                                                                           : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Spy x Family                                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Steins;Gate                                                                                                  : {[my_id, 0], [my_watched_episodes, 1], [my_status, Watching], [series_type, TV]…}
Tasogare Otome x Amnesia                                                                                     : {[my_id, 0], [my_watched_episodes, 1], [my_status, Watching], [series_type, TV]…}
Tejina-senpai                                                                                                : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Tensei Oujo to Tensai Reijou no Mahou Kakumei                                                                : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
To LOVE-Ru                                                                                                   : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Tokyo Ravens                                                                                                 : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Trinity Seven                                                                                                : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Uchi no Ko no Tame naraba, Ore wa Moshikashitara Maou mo Taoseru kamo Shirenai.                              : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Ueno-san wa Bukiyou                                                                                          : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Violet Evergarden                                                                                            : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Yuragi-sou no Yuuna-san                                                                                      : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}
Zom 100: Zombie ni Naru made ni Shitai 100 no Koto                                                           : {[my_id, 0], [my_watched_episodes, 0], [my_status, Watching], [series_type, TV]…}

Please keep in mind what we cannot see your screen and we cannot read your mind. So we need some explanation along with your code or sample data.

Again: What is your question?

i have try a new way of managing the xml with powershell , which i convert a xml file into the psobject and use add-member so each xpath of the xml become a member of the psobject

a = Get-Content C:\Users\34683\Downloads\animelist_1698994068_-_16067219.xml

$b = [xml]$a






function ConvertFrom-Xml($XML) {
    foreach ($Object in @($XML.myanimelist)) {
        $PSObject = New-Object PSObject
        
    foreach ($Property in @($Object.anime)) {
        $PSObject | Add-Member -NotePropertyMembers @{$Property.series_title.innertext=@{
           
          
         my_status=$Property.my_status
         series_type=$Property.series_type
         series_episodes=$Property.series_episodes
         my_id=$Property.my_id
         my_start_date=$Property.my_start_date
         my_watched_episodes=$Property.my_watched_episodes
         series_title=$Property.series_title.innertext
        my_finishdate=$Property.my_finish_date
            __="_____________"
   
        
        }
     }  
        }
 $PSObject

    }

}   


ConvertFrom-Xml $b

so i can manage the xml file with add-member or change the value in the member

i was trying to manage the website or something with powershell now that i can manage the xml file

is it posible to do it with powershell ?