$doc = New-Object System.Xml.XmlDocument
$doc.Load(“http://nykdev101.us.net.intra/carlos/amoncalltracker-temp-3-2011.nsf/%28XMLView%29?OpenAgent&view=%28StaffDetailsByRotation%29”)
$xml = [xml]($doc)
$xml.Save("C:/TEMP/data.xml")
我写的只是从远程网址保存一个相同的xml
这是oringnal .xml文件:
<xml version="1.0">
-<VIEW ID="DBA58FEDF4D">
-<DOC ID="A1D46BAD94">
-<APPNAME>
<![CDATA[ 1042%2OPRC]]>
</APPNAME>
<RTN/>
-<SUPPORTCONTACTNAME>
-<![CDATA[Emelie%20Pierrel]]>
</SUPPORTCONTACTNAME>
-<STCONTACT>
-<![CDATA[]]>
</STCONTACT>
-<NDCONTACT>
-<![CDATA[]]>
</NDCONTACT>
-<RDCONTACT>
-<![CDATA[201-850-6560]]>
</RDCONTACT>
-<THCONTACT>
</THCONTACT>
-<OFFICECONTACT>
</OFFICECONTACT>
</DOC>
我想删除所有' - '和',',这可能会导致显示错误。
我将如何写?
答案 0 :(得分:0)
$xmltext = Get-Content C:/TEMP/data.xml
$pattern = "-<"
$new = "<"
foreach($line in $xmltext) {
$replace = [regex]::replace($line, $pattern, $new)
echo $replace
}