asm0dey / staks

Kotlin wrapper for StAX
https://asm0dey.github.io/staks/staks/staks/index.html
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Syntax for getting a pair of a tag attribute and value simultaneously #1

Open Kryomancer opened 1 year ago

Kryomancer commented 1 year ago

I have an XML file with numerous entries like so:

<q_code qc_type="skip">4-7-1</q_code>
<q_code qc_type="sh_desc">0a7.14</q_code>
<q_code qc_type="four_corner">1010.6</q_code>
<q_code qc_type="deroo">3273</q_code>
<q_code>200</q_code>

For the death of me, I cannot come up with the correct syntax to aqcuire a List<Pair<String,String>> where one string is the attribute and another the value inside the tag. If I write something like list("q_code") then anything after it expects a child element and the attribute is lost and the list function does not appear to accept pairs. If this isn't possible, are there any other ways one might aqcuire both for an arbitrary number of these tags in some other usable format? Be aware that not all of these tags have the attribute and the relation between the attribute and the value is important, so something that returns a list of all the attribute values without the nulls in would not work. This is nested inside other tags that I can handle writing the code for, in case this matters.

asm0dey commented 1 year ago

Hm, it seems that I didn't think about such a matcher :(

asm0dey commented 1 year ago

But probably it might be solved by writing a custom handler! A handler that will return both the value of the argument and the text inside the tag!