下面我有一个用于跟踪库存的 Adobe XML swidtag 示例。我需要使用 bash 解析出相关信息并将其输出到一个新的文本文件。仅供参考,我在 Mac 上使用终端。
例如我想解析以下
swid:entitlement_required_indicator
swid:product_title
swid:product_version
swid:name
swid:numeric
swid:major
swid:minor
swid:build
swid:review
我试过使用
xmllint --xpath '//swid:product_version/swid:name/text()' nameoffile.xml
Creative Suite 5 的示例标签文件 以下示例适用于 Adobe Photoshop CS5,序列化为 Creative Suite 5 Master Collection (Suite)
<?xml version="1.0" encoding="utf-8"?>
<swid:software_identification_tag xsi:schemaLocation="http://standards.iso.org/iso/19770/-2/2008/schema.xsd software_identification_tag.xsd"
xmlns:swid="http://standards.iso.org/iso/19770/-2/2008/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--Mandatory Identity elements -->
<swid:entitlement_required_indicator>true</swid:entitlement_required_indicator>
<swid:product_title>Acrobat XI Pro</swid:product_title>
<swid:product_version>
<swid:name>1.0</swid:name>
<swid:numeric>
<swid:major>1</swid:major>
<swid:minor>0</swid:minor>
<swid:build>0</swid:build>
<swid:review>0</swid:review>
</swid:numeric>
</swid:product_version>
<swid:software_creator>
<swid:name>Adobe Systems Incorporated</swid:name>
<swid:regid>regid.1986-12.com.adobe</swid:regid>
</swid:software_creator>
<swid:software_licensor>
<swid:name>Adobe Systems Incorporated</swid:name>
<swid:regid>regid.1986-12.com.adobe</swid:regid>
</swid:software_licensor>
<swid:software_id>
<swid:unique_id>CreativeCloud-CS6-Mac-GM-MUL</swid:unique_id>
<swid:tag_creator_regid>regid.1986-12.com.adobe</swid:tag_creator_regid>
</swid:software_id>
<swid:tag_creator>
<swid:name>Adobe Systems Incorporated</swid:name>
<swid:regid>regid.1986-12.com.adobe</swid:regid>
</swid:tag_creator>
<!--Optional Identity elements -->
<swid:license_linkage>
<swid:activation_status>activated</swid:activation_status>
<swid:channel_type>SUBSCRIPTION</swid:channel_type>
<swid:customer_type>RETAIL</swid:customer_type>
</swid:license_linkage>
<swid:serial_number>909702426602037824854600</swid:serial_number>
</swid:software_identification_tag>