oy764fdのブログ

oy764fdのブログ

Javascritp、PHP、C言語、C++などのプログラムを勉強してる人のブログ

Amebaでブログを始めよう!

https://bgt-48.blogspot.com/2018/02/powershellxml-xmltextwriter.html
$xmldoc = [xml](Get-Content "c:\temp\books.xml")
$encod = [System.Text.Encoding]::UTF8
$xmlwriter= New-Object System.Xml.XmlTextWriter("c:\temp\books.xml", $encod)
$xmlwriter.Formatting = [System.Xml.Formatting]::Indented
$xmlwriter.IndentChars = "`t"
$xmldoc.Save(xmlwriter)
$xmlwriter.Close()


 

https://bgt-48.blogspot.com/2018/02/powershellxml-xmldocument.html

 

 

 

$xmldoc = [xml](Get-Content "c:\\temp\\books.xml")
$xmldoc.books.book[0].price = "1000"
$xmldoc.books.book[0].isbn = "1234567890"
$xmldoc.Save("c:\\temp\\books.xml")



<?xml version="1.0" encoding="utf-8"?>
<books>
<book isbn="kissy.blog.jp">
<title>ぶろぐはじめました</title>
<author>kissy</author>
<date>2017-09-02</date>
<price>10000</date>
</book>

<book isbn="abcdefghij">
<title>PowerShellはじめました</title>
<author>kissy</author>
<date>2017-09-03</date>
<price>1000</date>
</book>
</books>


https://hosopro.blogspot.com/2017/01/powershell-shift-jis-xml-edit.html

 

 



PS C:\work> $person = $x.User.Person[0]
PS C:\work> $person.Phone = "888-888-8888"
PS C:\work> $Encoding = [System.Text.Encoding]::GetEncoding("Shift_Jis")
PS C:\work> $xmlWriter = New-Object System.Xml.XmlTextWriter("C:\work\users.xml", $Encoding)
PS C:\work> $xmlWriter.Formatting = "Indented"
PS C:\work> $xmlWriter.Indentation = "4"
PS C:\work> $x.Save($xmlWriter)
PS C:\work> $xmlWriter.Close()