天天看點

[20160608]xmllint格式化xml.txt

[20160608]xmllint格式化xml.txt

$  gpnptool get -o-

<?xml version="1.0" encoding="UTF-8"?><gpnp:GPnP-Profile Version="1.0"

xmlns="http://www.grid-pnp.org/2005/11/gpnp-profile" xmlns:gpnp="http://www.grid-pnp.org/2005/11/gpnp-profile"

xmlns:orcl="http://www.oracle.com/gpnp/2005/11/gpnp-profile" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.grid-pnp.org/2005/11/gpnp-profile gpnp-profile.xsd" ProfileSequence="4"

ClusterUId="7332ecd0a54defd8bf0476778d26d8e1" ClusterName="xxxxxx"

PALocation=""><gpnp:Network-Profile><gpnp:HostNetwork id="gen" HostName="*"><gpnp:Network id="net1" IP="192.168.100.0"

Adapter="bondeth0" Use="public"/><gpnp:Network id="net2" IP="10.10.10.0" Adapter="ib0"

Use="cluster_interconnect"/><gpnp:Network id="net3" IP="10.10.10.0" Adapter="ib1"

Use="cluster_interconnect"/></gpnp:HostNetwork></gpnp:Network-Profile><orcl:CSS-Profile id="css" DiscoveryString="+asm"

LeaseDuration="400"/><orcl:ASM-Profile id="asm" DiscoveryString="o/*/*"

SPFile="+DBFS_DG/xxxxxx/asmparameterfile/registry.253.860619287"/><ds:Signature

xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod

Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod

Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform

Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform

Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <InclusiveNamespaces

xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="gpnp orcl

xsi"/></ds:Transform></ds:Transforms><ds:DigestMethod

Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>0tho9n/yT7+TOg3RKi7FXTANqMg=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>XoFD8hpkRJScvOprY56Afcsujl4UdSQfq0whrVlcDRKZ4k7+r3iGvNRQek8VS8rbxIgj3EKGdZxSgmI5xz7jZ+zYYkG7rEfavpCsGVjyjX78jTKlUb+SS1pl1mA9QEHRxR7evaTVsWHkFEdmSt5W6ptM9AT6I/p4+08AkZhP7C8=</ds:SignatureValue></ds:Signature></gpnp:GPnP-Profile>

Success.

--注:這裡的輸出實際上是一行,我格式化了.實際上使用xmllint很好格式化抽取裡面的資訊,例子:

$  gpnptool get -o- | xmllint --format - | grep SPFile

  <orcl:ASM-Profile id="asm" DiscoveryString="o/*/*" SPFile="+DBFS_DG/xxxxxx/asmparameterfile/registry.253.860619287"/>

$  rpm -qa | grep  libxml2

libxml2-2.6.26-2.1.21.0.1.el5_9.3

libxml2-python-2.6.26-2.1.21.0.1.el5_9.3

--具體的使用可以man xmllint檢視.