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 8753765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:29:16+00:00 2026-06-13T13:29:16+00:00

I have an XSL file, which acts as a configuration file for my application.

  • 0

I have an XSL file, which acts as a configuration file for my application. In fact it is an XML file, which has the <xsl:Stylesheet> elements wrapped around it. This file is called Config.xsl:

     <?xml version="1.0" encoding="UTF-8"?>
     <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"           xmlns="http://www.example.org/Config">
     <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"               standalone="yes" />
     <xsl:template match="/">
     <Config>
          <Test>somevalue</Test>
          <Test1>someothervalue</Test1>
     </Config>
     </xsl:template>
</xsl:stylesheet>

Now I would like to change the value of an element, which is passed dynamically.
Meaning, I have another XML file, which contains the XPATH and the value as key name/value pairs. Below is the contents of XML file Properties.xml.

<?xml version="1.0" encoding="utf-8" ?>
<ConfigFiles>
<ConfigFile>
    <FileName>Config.xsl</FileName>
    <Keys>
        <Key Name="Config.Test" Value="newvalue" />
        <Key Name="Config.Test1" Value="newvalue1" />
    </Keys>
</ConfigFile>   
</ConfigFiles>

Below is my powershell code, which is not updating the values of the elements.

$properties = [xml] (Get-Content Properties.xml)
$lstfiles = $properties.ConfigFiles.ConfigFile
foreach($file in $lstfiles)
{
  $configfilename = $file.FileName
  $filename = "C:\configs\configfilename"
  $testconfigfile = [xml] (Get-Content $filename)

  $lstKeys = $file.Keys.Key
  foreach($key in $lstKeys)
  {
    #When I debug the code, I was able to assign the value using the below code (Commented). However this is not dynamic
    #$testconfigfile.DocumentElement.LastChild.Config.Test = "newvalue"

    #Now if I try to pass the same values dynamically by reading them from properties.xml and assigning it using the below code it does not work
    $testconfigfile.DocumentElement.LastChild.$key.Name = $key.Value            
  }
  $testconfigfile.Save($filename)               
}
  • 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-06-13T13:29:18+00:00Added an answer on June 13, 2026 at 1:29 pm

    This should work for you. Change the properties.xml to

    <?xml version="1.0" encoding="utf-8" ?>
    <ConfigFiles>
    <ConfigFile>
        <FileName>Config.xsl</FileName>
        <Keys>
            <Key Name="Test" Value="newvalue" />
            <Key Name="Test1" Value="newvalue1" />
        </Keys>
    </ConfigFile>   
    </ConfigFiles>
    

    and try the below line in your shell script ,

    $testconfigfile.DocumentElement.LastChild.Config.($key.Name) = $key.Value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple XSL file which looks like: <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform version=1.0>
I have an XML file which is transformed with XSL. Some elements have to
So I have this .inc file which has a set of <li> elements like
I have an .xml file which has an accompanying .xsl file. The output of
I have this PHP web application. It has a link to an XML file
I have a big (1.9 GB) XML file which has data I want to
I have an xml file which describes (among other things) elements with attribute values
I've got an XML file which looks somehow like this: <?xml version='1.0' encoding='UTF-8'?> <?xml-stylesheet
Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project
I have an xml file which I need to group-by using xsl:for-each-group. Everything works

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.