0

我怎样才能得到curljust <notes/>, from eXist, with的结果PowerShell

PS /home/nicholas> 
PS /home/nicholas> $url='http://localhost:8080/exist/rest/db/scripts/notes.xq'
PS /home/nicholas> 
PS /home/nicholas> $url                                                       
http://localhost:8080/exist/rest/db/scripts/notes.xq
PS /home/nicholas> 
PS /home/nicholas> $result=Invoke-RestMethod -Method Get -Uri $url -Headers @{"Content-Type" = "text/xml"}
PS /home/nicholas> 
PS /home/nicholas> $result

notes
-----


PS /home/nicholas> 
PS /home/nicholas> $result | Export-Clixml ./result.xml
PS /home/nicholas> 
PS /home/nicholas> Get-Content ./result.xml                                                               
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <XD>&lt;notes /&gt;</XD>
  </Obj>
</Objs>
PS /home/nicholas> 
PS /home/nicholas> exit
nicholas@mordor:~$ 
nicholas@mordor:~$ curl http://localhost:8080/exist/rest/db/scripts/notes.xq
<notes/>nicholas@mordor:~$ 
nicholas@mordor:~$ 

为什么上面XMLXD标签,目的是什么?

帮助文件指出:

描述

Export-Clixmlcmdlet 创建一个或多个对象的基于公共语言基础结构 (CLI) XML 的表示并将其存储在文件中。然后,您可以使用Import-Clixmlcmdlet 根据该文件的内容重新创建保存的对象。有关 CLI 的详细信息,请参阅语言独立性 (/dotnet/standard/language-independence)。

This cmdlet is similar to `ConvertTo-Xml`, except that `Export-Clixml` stores the resulting XML in a file. `ConvertTo-XML` 
returns the XML, so you can continue to process it in PowerShell.

A valuable use of `Export-Clixml` on Windows computers is to export credentials and secure strings securely as XML. For an 
example, see Example 3.
4

1 回答 1

0

调用OuterXml作品:

PS /home/nicholas> 
PS /home/nicholas> $url                                                                                   
http://localhost:8080/exist/rest/db/scripts/notes.xq
PS /home/nicholas> 
PS /home/nicholas> $result=Invoke-RestMethod -Method Get -Uri $url -Headers @{"Content-Type" = "text/xml"}
PS /home/nicholas> 
PS /home/nicholas> $result.OuterXml                                                                       
<notes />
PS /home/nicholas> 
PS /home/nicholas> ($result | ConvertTo-Xml).OuterXml                                                     
<?xml version="1.0" encoding="utf-8"?><Objects><Object Type="System.Xml.XmlDocument">System.Xml.XmlDocument</Object></Objects>
PS /home/nicholas> 

但是你怎么检查它XML呢?或者,甚至是格式良好的?

于 2020-11-19T07:42:32.730 回答