【问题标题】:How do I convert a REST API answer to proper XML using PowerShell?如何使用 PowerShell 将 REST API 答案转换为正确的 XML?
【发布时间】:2021-01-15 23:19:51
【问题描述】:

我正在尝试使用 PowerShell 解析 SharePoint 网站中使用的标识名称。

请求很简单:

(Invoke-WebRequest -Uri https://<siteaddress>/_api/web/SiteLogoUrl -UseDefaultCredentials).content

生成xml

<?xml version="1.0" encoding="utf-8"?>
<d:SiteLogoUrl xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
    xmlns:georss="http://www.georss.org/georss"
    xmlns:gml="http://www.opengis.net/gml">/<sitepath>/SiteAssets/Logo_name.jpg</d:SiteLogoUrl>

但是,尝试将其转换为 XML 只会创建“空”数据

[xml]((Invoke-WebRequest -Uri https://<siteaddress>/_api/web/SiteLogoUrl -UseDefaultCredentials).Content).SiteLogoUrl

【问题讨论】:

    标签: xml powershell rest sharepoint


    【解决方案1】:

    哦,我傻了……

    ([xml](Invoke-WebRequest -Uri https://<siteaddress>/_api/web/SiteLogoUrl -UseDefaultCredentials).Content).SiteLogoUrl
    
    d      : http://schemas.microsoft.com/ado/2007/08/dataservices
    m      : http://schemas.microsoft.com/ado/2007/08/dataservices/metadata
    georss : http://www.georss.org/georss
    gml    : http://www.opengis.net/gml
    #text  : /<SITEPATH>/SiteAssets/Logo_name.jpg
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      • 2021-05-20
      • 2022-06-18
      • 1970-01-01
      • 1970-01-01
      • 2017-09-09
      相关资源
      最近更新 更多