• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

Convert JSON FILE to XML FILE using POWERSHELL (1 Viewer)

MBMSOFT

Registered User.
Local time
Today, 15:48
Joined
Jan 29, 2010
Messages
90
I need to convert json file from web to xml file and i need very simple way... There are several data I need from json response... There are a lot of around but they are not very clear...
I found some samples like this:
PS c:\0> ConvertTo-Xml -InputObject temp_JSON.json -As String
PS c:\0> ConvertTo-Xml -InputObject temp_JSON.json -As document

but I can't see or find result
Where I'm wrong...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:48
Joined
Oct 29, 2018
Messages
12,442
Hi. According to MS documentation, the CovertTo-XML cmdlet produces an XML structure in memory.
 

MBMSOFT

Registered User.
Local time
Today, 15:48
Joined
Jan 29, 2010
Messages
90
yes but how can I get the xml file after i run script
I run this
PS c:\0> ConvertTo-Xml -InputObject temp_JSON.json -As document
where is the file
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:48
Joined
Oct 29, 2018
Messages
12,442
Hi. I'm no PowerShell user, so I unsuccessfully gave it a try last night and decided to sleep over it. This morning, I gave it another try, and this one worked for me.

I am not saying this is how you would do it, but it might help with what you're trying to do. Good luck!

Code:
new-item test.xml
$data = $(get-content 'json.txt' -raw)
$json = convertfrom-json -inputobject $data
[xml]$xml = convertto-xml -depth 1000 $json -notypeinformation
set-content test.xml $xml.outerxml
[code]
 

Users who are viewing this thread

Top Bottom