У меня есть такой XML-код:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://.../nuget/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Packages</title>
<id>http://.../nuget/Packages</id>
<updated>2019-06-24T08:30:28Z</updated>
<link rel="self" title="Packages" href="Packages" />
<id>http://.../nuget/Packages(Id='7zip',Version='16.0.2')</id>
<title type="text">programma</title>
<summary type="text">Programma is a file archiver with a high compression ratio.</summary>
<updated>2018-06-19T15:33:22Z</updated>
<author>
<name>Herman</name>
</author>
<link rel="edit-media" title="ODataPackage" href="Packages(Id='7zip',Version='16.0.2')/$value" />
<link rel="edit" title="ODataPackage" href="Packages(Id='7zip',Version='16.0.2')" />
<category term="NuGet.Server.DataServices.ODataPackage"scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/zip" src="http://.../api/v2/package/7zip/16.0.2" />
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<d:Version>16.0.2</d:Version>
<d:NormalizedVersion>16.0.2</d:NormalizedVersion>
<d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
<d:Title>7-Zip</d:Title>
<d:Owners>Herman</d:Owners>
<d:IconUrl m:null="true"></d:IconUrl>
<d:LicenseUrl>http://www.7-zip.org/license.txt</d:LicenseUrl>
<d:ProjectUrl>http://www.7-zip.org/</d:ProjectUrl>
<d:DownloadCount m:type="Edm.Int32">-1</d:DownloadCount>
<d:RequireLicenseAcceptance m:type="Edm.Boolean">false</d:RequireLicenseAcceptance>
<d:DevelopmentDependency m:type="Edm.Boolean">false</d:DevelopmentDependency>
<d:Description>7-Zip is a file archiver with a high compression ratio.
Используя Xpath, следующий код в Powershell дает некоторые значения для $ entry:
$xpath = "//atom:title[contains(text(),'$ChocoPackageName')]"
$entry = $xml | Select-Xml -XPath $xpath -Namespace @{atom="http://www.w3.org/2005/Atom"}
$entry | Should Not BeNullOrEmpty
Теперь мне нужно создать xpathчтобы найти узел с определенной версией (16.0.2) в версии в свойствах
, я произвел:
$xpath = "//Version[contains(text(), '$Version')]"
$entry = $xml | Select-Xml -XPath $xpath -Namespace @{atom="http://www.w3.org/2005/Atom"}
$entry | Should Not BeNullOrEmpty
Я не могу заставить его работать.Что бы я ни использовал в определении XPath.Как определить $ xpath для подачи / записи / свойств / версии
Пожалуйста, помогите!