从powershell读取KML

问题描述 投票:-1回答:1

我有kml(xml)。我想阅读并进一步处理。示例:

<?xml version="1.0" encoding="UTF-8"?> 
 <kml xmlns="http://www.opengis.net/kml/2.2"> 
 <Document><Placemark> 
 <Point> 
 <coordinates> 30.142550,49.797350,0 </coordinates> 
 </Point> 
 </Placemark><Placemark> 
 <Point> 
 <coordinates> 30.142533,49.797333,0 </coordinates> 
 </Point> 
 </Placemark><Placemark> 
 <Point> 
 <coordinates> 30.142517,49.797283,0 </coordinates> 
 </Point> 
 </Placemark></Document> 
 </kml>

而且我正在尝试阅读它:

Select-Xml -Path $Path -XPath $Xpath -Namespace $XmlNamespace | Select-Object -ExpandProperty Node
$Path = "D:\temp\test\4.kml"
$xpath = "kml/Document/Placemark/Point"
$XmlNamespace = @{ default = '"http://www.opengis.net/kml/2.2"'; };
Select-Xml -Path $Path -XPath $Xpath -Namespace $XmlNamespace | Select-Object -ExpandProperty Node

但是没有结果...为什么?

xml powershell kml
1个回答
0
投票

由于您使用的是默认名称空间,并已选择命名(默认),因此需要在所有节点之前添加该名称前缀。另外,您的名称空间定义不需要包含文字引号。

© www.soinside.com 2019 - 2024. All rights reserved.