Last active
June 7, 2021 11:56
-
-
Save chumpa/10d5129e59ae1b320c3a10bd670f2bc2 to your computer and use it in GitHub Desktop.
XmlSlurper атрибуты
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import groovy.util.slurpersupport.GPathResult | |
| import org.junit.Test | |
| class CpiLearning2 { | |
| String xml = """<Файл ИдФайл="NO_PRIB_0007_0007_" ВерсПрог="КОНТУР-ЭКСТЕРН, ВЕРСИЯ 14.0" ВерсФорм="5.07" id = "1" parentid = ""> | |
| <Документ КНД="1151006" ДатаДок="31.05.2019" Период="36" ОтчетГод="2019" КодНО="0007" НомКорр="0" ПоМесту="213" id="2" parentid="1"> | |
| <СвНП ОКВЭД="06.10.01" Тлф="+7900-000000000" id="3" parentid="2"> | |
| <азаза атр="знач"/> | |
| </СвНП> | |
| </Документ> | |
| </Файл>""" | |
| @Test | |
| void a() { | |
| XmlSlurper xs = new XmlSlurper(false, true) | |
| GPathResult src = xs.parseText(xml) | |
| for (groovy.util.slurpersupport.Node n in src.nodeIterator()) { | |
| Map<String,String> attrs = n.attributes() | |
| println(attrs) | |
| for (groovy.util.slurpersupport.Node ch: src.childNodes()) { | |
| println(ch.name()) | |
| println (ch.attributes()) | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[ВерсПрог:КОНТУР-ЭКСТЕРН, ВЕРСИЯ 14.0, ВерсФорм:5.07, ИдФайл:NO_PRIB_0007_0007_, id:1, parentid:]
Документ
[Период:36, ПоМесту:213, НомКорр:0, ОтчетГод:2019, id:2, КодНО:0007, ДатаДок:31.05.2019, parentid:1, КНД:1151006]