|
From: | Alfredo Casanova |
Subject: | Re: [shell-script] Filtrar XML |
Date: | Wed, 09 Dec 2015 16:57:11 +0000 |
vamos laisso é um xml, lide com isso como se fosse um xml. existem ferramentas especificas para tratar com xml e vc tem um arquivo que representa um tipo muito abstrato de informação.existe a chance disso dar errado se vc trata xml como texto. se o formato é comportado vc ate pode lidar porém uma coisinha diferente vai te dar um resultado todo errado. acredite.por exemplo, se vc usar o xmllint + xpath por //*[yay="true"]$ cat a.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<foo></foo>
<bar><yay>true</yay></bar>
<baz><yay>true</yay></baz>
<bam><yay>false</yay></bam>
</root>$ xmllint a.xml --shell
/ > cat //*[yay="true"]
-------
<bar>
<yay>true</yay>
</bar>
-------
<baz>
<yay>true</yay>
</baz>Isso ja te da algumas ideias. infelizmente o xmllint não é muito amigavel e varias coisas não deram muito certo ( acho overkill ter q usar expect so pra mandar o comandos para ele uma vez que o --xpath retorna tudo junto 'inline'boa sorte.2015-12-09 16:22 GMT+01:00 César Vianna address@hidden [shell-script] <address@hidden>:Boa tarde!
Tenho um arquivo XML com o seguinte padrão :<tagx>
....
....
</tagx>
<tagy>
....
<tagz>true</tagz>
....
</tagy>
<tagy>
....
<tagz>false</tagz>
....
</tagy>Preciso filtrar todos os blocos de tagy que contenham a tagz com true.
Com grep e sed só consigo tratar linha a linha. Acho que a saída é awk.
Alguma ideia?--
[Prev in Thread] Current Thread [Next in Thread]
- Filtrar XML, César Vianna, 2015/12/09
- Re: [shell-script] Filtrar XML, Tiago Peczenyj, 2015/12/09
- Re: [shell-script] Filtrar XML, Alfredo Casanova <=
- Re: [shell-script] Filtrar XML, Alfredo Casanova, 2015/12/09
- Re: [shell-script] Filtrar XML, Luiz Alberto, 2015/12/10
- Re: [shell-script] Filtrar XML, Luiz Alberto, 2015/12/10
Re: Filtrar XML, itamarnet, 2015/12/09
- Prev by Date: Re: [shell-script] Filtrar XML
- Next by Date: Re: [shell-script] Filtrar XML
- Previous by thread: Re: [shell-script] Filtrar XML
- Next by thread: Re: [shell-script] Filtrar XML
- Index(es):