This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm trying to take an XML file that has 2 trees of values, a header and the data portion. I'm trying to edit multiple values in the header section, not touching the data tree and then save out the file. On the new file any value pair <ValueHere></ValueHere> that has no data is getting what looks like a carriage return/new line added so now the tool that reads the files is saying it's invalid. The example file I'm using goes from 3400 lines to 3724 lines now. I'm using the following to read and save out the file, perhaps I'm doing it wrong as I am weak on XML manipulation.
[XMXL]$Result = Get-Content -Path "C:\File.xml"
$XMLData.Save($NewFile)
Do I need to create a loop to manually try and state a null value in each empty pair or is there a way to make the data tree of values immutable? Or is there a better way to manipulate the XML file that I haven't found yet?
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PowerShell/...