我有xml文件,格式如下,我想在csv otput中進行轉換,如下所示。不幸的是我不允許安裝xmlstarlet或其他xml解析器(我只有xmllint)。我怎麼能做到這一點,例如使用時,awk,sed的....Xml文件到CSV輸出
<xn:VsDataContainer id="site00881">
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008811,ManagedElement=1</es:listOfNe>
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008819,ManagedElement=1</es:listOfNe>
</xn:VsDataContainer>
<xn:VsDataContainer id="site00882">
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008821,ManagedElement=1</es:listOfNe>
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008829,ManagedElement=1</es:listOfNe>
</xn:VsDataContainer>
<xn:VsDataContainer id="site00883">
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=ASDTUR13,MeContext=rbs008831,ManagedElement=1</es:listOfNe>
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=ASDTUR_SIU,MeContext=siu008832,ManagedElement=siu008832</es:listOfNe>
</xn:VsDataContainer>
<xn:VsDataContainer id="site00884">
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008841,ManagedElement=1</es:listOfNe>
<es:listOfNe>SubNetwork=NL1_R,SubNetwork=AHPTUR14,MeContext=rbs008849,ManagedElement=1</es:listOfNe>
</xn:VsDataContainer>
輸出應爲csv格式
rbs008811,site00881
rbs008819,site00881
rbs008821,site00882
rbs008829,site00882
rbs008831,site00883
siu008832,site00883
rbs008841,site00884
rbs008849,site00884
我不確定你可以。嘗試在沒有XML解析器的情況下解析XML [這是讓自己瘋狂的好方法](http://stackoverflow.com/a/1732454/4200092)。順便說一句,爲什麼你「不允許安裝」你所需要的工具? – GoBusto 2015-02-10 16:20:15