小编use*_*928的帖子

苦苦于xmlstarlet

我有一个非常简单的XML文件,我需要用xmlstarlet解析(我在Windows下):

<?xml version="1.0" encoding="utf-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <pain.001.001.02>
    <GrpHdr>
      <MsgId>IDENTIFYER</MsgId>
      <CreDtTm>2013-01-25T11:15:02</CreDtTm>
      <NbOfTxs>6</NbOfTxs>
      <CtrlSum>6268.07</CtrlSum>
      <Grpg>MIXD</Grpg>
    </GrpHdr>
   <PmtInf>
   </PmtInf>
  </pain.001.001.02>
</Document>
Run Code Online (Sandbox Code Playgroud)

假设我想要检索CtrlSum元素; 我尝试时失败了

xml sel -t -m "/Document/pain.001.001.02/GrpHdr" -v CtrlSum myfile.xml
Run Code Online (Sandbox Code Playgroud)

但是如果我从文件中删除xmlns和xmlns:xsi属性它可以工作(但我不能在现实生活中这样做).我知道我必须使用-N选项,但我无法想象如何做到这一点.任何帮助都是非常有价值的.

非常感谢Laurent(或Lawrence,或Larry :))

xml xmlstarlet

2
推荐指数
1
解决办法
2025
查看次数

标签 统计

xml ×1

xmlstarlet ×1