Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:52:59+00:00 2026-05-28T01:52:59+00:00

I have some data that I read from the registry and wish to modify.

  • 0

I have some data that I read from the registry and wish to modify. Example data looks like this:

<User Blob>
    <Item>
        <Key>SomeKey</Key>
        <Value>false</Value>
    </Item>
    <Item>
        <Key>AnotherKey</Key>
        <Value></Value>
    </Item>
</User Blob>
<Primary Server Blob>
    <Item>
        <Key>Just a key</Key>
        <Value></Value>
    </Item>
    <Item>
        <Key>And another key</Key>
        <Value>true</Value>
    </Item>
</Primary Server Blob>

I want to be able to change a certain key’s value. For example:

User Blob.SomeKey = $true

I tried to cast the data to XML or to a HashTable but this gives errors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:53:00+00:00Added an answer on May 28, 2026 at 1:53 am

    Generally, if you have XML data which you wish to modify (not just read), and the data is of a small-enough size (to avoid loading massive objects into memory), you would want to use a Document of some kind. Due to its ability to make use of XPath, I would recommend XmlDocument. (XPath makes this sort of problem simple.)

    As you rightly point out though, you will need a single XML root. That’s easy to solve though – just wrap whatever data you have in another root node.

    So here’s some code which should do the trick.

    $data = @"
    <UserBlob>
        <Item>
            <Key>SomeKey</Key>
            <Value>false</Value>
        </Item>
        <Item>
            <Key>AnotherKey</Key>
            <Value></Value>
        </Item>
    </UserBlob>
    <PrimaryServerBlob>
        <Item>
            <Key>Just a key</Key>
            <Value></Value>
        </Item>
        <Item>
            <Key>And another key</Key>
            <Value>true</Value>
        </Item>
    </PrimaryServerBlob>
    "@
    
    $wrappedData = "<root>$data</root>"
    $doc = new-object Xml.XmlDocument
    $doc.LoadXml($wrappedData)
    $nodeToChange = $doc.SelectSingleNode("/root/UserBlob/Item[Key='SomeKey']")
    if($nodeToChange){
        $nodeToChange.Value = "NEW VALUE"
    }
    $doc.Save("[PATH_TO_OUTPUT_FILE]")
    

    I’ve omitted error handling and correct disposal of objects for brevity. I’ll leave that up to you. 🙂

    For more info about XmlDocument, see the documentation.

    UPDATE

    To remove the additional root document again, just use this to get it as a string.

    $newWrappedData = $doc.Root.InnerXml
    

    Then save the string using a StreamWriter or File.CreateText or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data that looks something like this... +----------+----------+----------+ | Column 1 |
I have a code that read list from some paged string data. What I
I have some configuration data in a config file that I read off disk
I have some data that I would like to visualize. Each byte of the
I have some data that comes regularily as a dump from a data souce
I have an application that uses the bluetooth to receive some data (bytes) from
I have some status data that I want to cache from a database. Any
I have some data which I am formatting like this: // ... imagine populating
I have some read-only data that I want to initialise and then re-initialise periodically
I have some json data [{a:10, b:123,c:4.5},{a:2,b:5,c:33}] and so on that I read into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.