How to parse this xml?

Hello all, i’m very new to powershell, and i’m abit stuck.

I have this innerXML:

<sl-test.protocol>HTTP</sl-test.protocol>
<sl-test.responseTimeout>14000</sl-test.responseTimeout>
${myenv}
<http.port>8081</http.port>

And i want to convert it into a .properties file in this format:

sl-test.protocol=HTTP
sl-test.responseTimeout=14000
test=${myenv}
http.port=8081

i have the part to create the .properties file (hardcoded value right now) which works:

$test = New-Item -Name "mule-app.properties" -ItemType "file" -Value "test.prop=testprop`ntest2.prop=test2prop"

So basically i need to go from the innerXML to a big string of key/values separated by `n But also i need to escape any $ with `

desired string: sl-test.protocol=HTTP`nsl-test.responseTimeout=14000`ntest`${myenv}`nhttp.port=8081

But right now i cant even seem to iterate through all the keys and values.

Note: the keys and values will be dynamic, it will not always be those 4

Any help will be greatly appreciated.

Harry,
Welcome to the forum. :wave:t4:

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.

Thanks

And BTW: 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 <---- Click :point_up_2:t4: :wink: