excel - 在 Excel 中通过 XMLFilter 过滤 XML,但 XPath 错误
问题描述
我有一个要从中过滤标题和电子邮件的 XML。
这是 XML:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="https://mysite/vis/_api/">
<id>https://mysite/vis/_api/Web/GetUserById(1284)</id>
<category term="SP.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/GetUserById(1284)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Groups" type="application/atom+xml;type=feed" title="Groups" href="Web/GetUserById(1284)/Groups" />
<title />
<updated>2020-01-15T18:23:48Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">1284</d:Id>
<d:IsHiddenInUI m:type="Edm.Boolean">false</d:IsHiddenInUI>
<d:LoginName>i:0#.w|opmain\xespsa</d:LoginName>
<d:Title>Alex, Johnson</d:Title>
<d:PrincipalType m:type="Edm.Int32">1</d:PrincipalType>
<d:Email>Alex.Johnson@stackoverflow.net</d:Email>
<d:IsSiteAdmin m:type="Edm.Boolean">false</d:IsSiteAdmin>
<d:UserId m:type="SP.UserIdInfo">
<d:NameId>s-1-5-21-1377870913-3677095212-3270174719-20443</d:NameId>
<d:NameIdIssuer>urn:office:idp:activedirectory</d:NameIdIssuer>
</d:UserId>
</m:properties>
</content>
</entry>
我尝试使用 Excel 中的 XMLFILTER 函数,但我的 XPath 错误:
=XMLFILTERN(E4;"//content/title[1]")
在这种情况下,由于 Title 在内容中,我怎样才能获得正确的 xpath?
解决方案
对于 Excel 中的 xPath 参数,您应该使用命名空间:
完整路径:
//content/m:properties/d:Title
//content/m:properties/d:Email
在您的特定情况下,您可以更简单地使用:
//d:Title
//d:Email
推荐阅读
- css - 将 React 组件传递给 CSS 伪元素内容属性
- ruby-on-rails - Ruby on rails - 添加一个选择标签来搜索不同的字段
- amazon-web-services - 如何从远程执行的 Fargate 任务访问 S3 对象?
- kotlin - 在可组合层次结构中触发重组
- c# - 如何在axios post上将数据作为字符串而不是json发送
- angular - Angular -> 没有依赖模板:ConstDependency
- amazon-web-services - 使用 aws cli 过滤导出的数据 cloudFormation
- postgresql - 具有数千个分区的 Postgres 表
- npm - 当我尝试运行“npm install 或任何 npm 命令”时,我遇到了这个问题
- ios - iOS 中 CFBundleVersion 和 CFBundleShortVersionString 可接受的字符串格式是什么?