我需要幫助解析shell腳本中的xml文件,我需要從給定的xml文件中提取值,並將它們放到變量中。下面是XML文件的從xml文件中提取值bash
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Site SYSTEM "SiteEquipment.dtd" >
<!-- Site Equipment Configuration -->
<Site>
<Format
revision="AK5"
/>
<OptionalEquipmentConfiguration
configureSau="NO"
absoluteTimeSynchEnabled="NO"
gpsOutEnabled="FALSE"
smokeDetector="FALSE"
/>
<SiteLocationConfiguration
siteName="Alzey002"
logicalName="FXU046"
>
<SectorData
sectorNumber="1"
latitude="4635826"
latHemisphere="NORTH"
longitude="377963"
geoDatum="DHDN-"
beamDirection="060"
height="3000"
sectorGroup="-1"
/>
<SectorData
sectorNumber="2"
latitude="4635826"
latHemisphere="NORTH"
longitude="377963"
geoDatum="DHDN-"
beamDirection="140"
height="3000"
sectorGroup="-1"
/>
<SectorData
sectorNumber="3"
latitude="4635826"
latHemisphere="NORTH"
longitude="377963"
geoDatum="DHDN-"
beamDirection="300"
height="3000"
sectorGroup="-1"
/>
</SiteLocationConfiguration>
<SectorCapabilitySettings>
<SectorCapability
radioBuildingBlock="RBB12_1A"
cpriLineRate="Ox4"
sectorNumber="1"
primaryPortId="BU1_A"
sectorSequenceNumber="1"
rruInstalled="NO"
/>
<SectorCapability
radioBuildingBlock="RBB12_1A"
cpriLineRate="Ox4"
sectorNumber="2"
primaryPortId="BU1_B"
sectorSequenceNumber="1"
rruInstalled="NO"
/>
<SectorCapability
radioBuildingBlock="RBB12_1A"
cpriLineRate="Ox4"
sectorNumber="3"
primaryPortId="BU1_C"
sectorSequenceNumber="1"
rruInstalled="NO"
/>
</SectorCapabilitySettings>
<SectorEquipmentConfiguration>
<TmaConfiguration>
<TmaSector
sectorNumber="1"
tmaType="NONE"
tmaType2="NONE"
tmaType3="NONE"
typeOfRet="RETU"
typeOfRet2="NONE"
typeOfRet3="NONE"
riuInstalled="NO"
riuInstalled2="NO"
currentLowSupervision_A="ON"
currentLowSupervision_B="ON"
currentLowSupervision_C="ON"
currentLowSupervision_D="ON"
/>
<TmaSector
sectorNumber="2"
tmaType="NONE"
tmaType2="NONE"
tmaType3="NONE"
typeOfRet="RETU"
typeOfRet2="NONE"
typeOfRet3="NONE"
riuInstalled="NO"
riuInstalled2="NO"
currentLowSupervision_A="ON"
currentLowSupervision_B="ON"
currentLowSupervision_C="ON"
currentLowSupervision_D="ON"
/>
<TmaSector
sectorNumber="3"
tmaType="NONE"
tmaType2="NONE"
tmaType3="NONE"
typeOfRet="RETU"
typeOfRet2="NONE"
typeOfRet3="NONE"
riuInstalled="NO"
riuInstalled2="NO"
currentLowSupervision_A="ON"
currentLowSupervision_B="ON"
currentLowSupervision_C="ON"
currentLowSupervision_D="ON"
/>
</TmaConfiguration>
<AntennaConfiguration>
<AntennaSector
sectorNumber="1"
antennaType="2"
antennaType2="0"
antennaType3="0"
mechanicalTilt="0"
mechanicalTilt2="0"
mechanicalTilt3="0"
electricalTilt="30"
band="1"
fqBandHighEdgeBranchA="21250"
fqBandLowEdgeBranchA="21100"
fqBandHighEdgeBranchB="21250"
fqBandLowEdgeBranchB="21100"
fqBandHighEdgeBranchC=""
fqBandLowEdgeBranchC=""
fqBandHighEdgeBranchD=""
fqBandLowEdgeBranchD=""
fqBandHighEdgeBranchE=""
fqBandLowEdgeBranchE=""
fqBandHighEdgeBranchF=""
fqBandLowEdgeBranchF=""
dlFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
sectorOutputPower="60"
beamDirection="060"
beamDirection2="000"
beamDirection3="000"
/>
<AntennaSector
sectorNumber="2"
antennaType="2"
antennaType2="0"
antennaType3="0"
mechanicalTilt="0"
mechanicalTilt2="0"
mechanicalTilt3="0"
electricalTilt="0"
band="1"
fqBandHighEdgeBranchA="21250"
fqBandLowEdgeBranchA="21100"
fqBandHighEdgeBranchB="21250"
fqBandLowEdgeBranchB="21100"
fqBandHighEdgeBranchC=""
fqBandLowEdgeBranchC=""
fqBandHighEdgeBranchD=""
fqBandLowEdgeBranchD=""
fqBandHighEdgeBranchE=""
fqBandLowEdgeBranchE=""
fqBandHighEdgeBranchF=""
fqBandLowEdgeBranchF=""
dlFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
sectorOutputPower="60"
beamDirection="140"
beamDirection2="000"
beamDirection3="000"
/>
<AntennaSector
sectorNumber="3"
antennaType="2"
antennaType2="0"
antennaType3="0"
mechanicalTilt="0"
mechanicalTilt2="0"
mechanicalTilt3="0"
electricalTilt="60"
band="1"
fqBandHighEdgeBranchA="21250"
fqBandLowEdgeBranchA="21100"
fqBandHighEdgeBranchB="21250"
fqBandLowEdgeBranchB="21100"
fqBandHighEdgeBranchC=""
fqBandLowEdgeBranchC=""
fqBandHighEdgeBranchD=""
fqBandLowEdgeBranchD=""
fqBandHighEdgeBranchE=""
fqBandLowEdgeBranchE=""
fqBandHighEdgeBranchF=""
fqBandLowEdgeBranchF=""
dlFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchA="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederAttenuationBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
dlFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
ulFeederDelayBranchB="0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1"
sectorOutputPower="60"
beamDirection="300"
beamDirection2="000"
beamDirection3="000"
/>
</AntennaConfiguration>
<InitiateSectorsConfiguration>
<InitiatedSector
sectorNumber="1"
antennaSupervisionBranchA="10"
antennaSupervisionBranchB="10"
antennaSupervisionBranchC="0"
antennaSupervisionBranchD="0"
antennaSupervisionBranchE="0"
antennaSupervisionBranchF="0"
/>
<InitiatedSector
sectorNumber="2"
antennaSupervisionBranchA="10"
antennaSupervisionBranchB="10"
antennaSupervisionBranchC="0"
antennaSupervisionBranchD="0"
antennaSupervisionBranchE="0"
antennaSupervisionBranchF="0"
/>
<InitiatedSector
sectorNumber="3"
antennaSupervisionBranchA="10"
antennaSupervisionBranchB="10"
antennaSupervisionBranchC="0"
antennaSupervisionBranchD="0"
antennaSupervisionBranchE="0"
antennaSupervisionBranchF="0"
/>
</InitiateSectorsConfiguration>
<LocalCellConfiguration
carrierAllocationMode="Flexible"
>
<Sector
sectorNumber="1"
>
<Cell
cellNumber="1"
cellCreated="YES"
cellIdentity="461"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="2"
cellCreated="YES"
cellIdentity="465"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="3"
cellCreated="YES"
cellIdentity="468"
cellRange="35000"
baseBandPoolId="1"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
</Sector>
<Sector
sectorNumber="2"
>
<Cell
cellNumber="1"
cellCreated="YES"
cellIdentity="462"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="2"
cellCreated="YES"
cellIdentity="466"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="3"
cellCreated="YES"
cellIdentity="469"
cellRange="35000"
baseBandPoolId="1"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
</Sector>
<Sector
sectorNumber="3"
>
<Cell
cellNumber="1"
cellCreated="YES"
cellIdentity="463"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="2"
cellCreated="YES"
cellIdentity="467"
cellRange="35000"
baseBandPoolId="2"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
<Cell
cellNumber="3"
cellCreated="YES"
cellIdentity="460"
cellRange="35000"
baseBandPoolId="1"
numberOfTxBranches="1"
numberOfRxBranches="2"
/>
</Sector>
</LocalCellConfiguration>
</SectorEquipmentConfiguration
所以我需要提取examle一些值,cellIdentity
值的每個部門在數據
Sector 1
VAR1=461
VAR2=465
VAR3=468
Sector 2
VAR4=462
VAR5=466
VAR6=469
Sector 3
VAR7=463
VAR8=467
VAR9=460
我試着用xmllint的一部分,但我得到了一些錯誤:
/usr/bin/xmllint --shell 1.xml <<<"cat/<Site/LocalCellConfiguration/Sector/Cell/cellIdentity/" | grep -v "^/ >"
那麼我不是很熟悉xmllint,但我需要看看它是如何工作的,以便我可以從文件中提取其他值。 謝謝
是否爲第二灰度塊代表你正在尋找的輸出?你想製作另一個文件嗎?或從XML加載一些變量? –
第二個塊是我想要的輸出,basicliy我需要這些值在變量中,以便我可以顯示它們,或稍後使用它們...... – user3319356