-
Hello, I'm using KMM with Okio, and i'm triying to serialise/parse a large xml file, I see on https://docs.korge.org/korio/serialization/ how to parse a String but since my file is too large, im triying to parse the stream :
Thanks for your help if you have a solution |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
It is not posible right now. Xml streaming uses StrReader that was designed to use a String in memory. It was like that to be as fast as possible (no virtual methods, no suspension points, all in-memory). |
Beta Was this translation helpful? Give feedback.
-
Thank you very muh for looking into it . What i'm triying to do it's too parse an xml file with korio on common main of kmm to avoid specific code for android and ios , currently on android i'm using a java library to serialise like this :
PS: I'm also facing the same kindof issue when extracting a "large" .zip file with file with korio :
|
Beta Was this translation helpful? Give feedback.
-
Supported since this PR: #1180 Example: @Test
fun testNamedDescendantStreamInfinite() {
val xml = Xml.Stream.parse(sequenceSyncStream {
while (true) {
yield("<xml>".toByteArray())
}
}.toCharReader(UTF8))
assertEquals(
"""
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
OpenTag(name=xml, attributes={})
""".trimIndent(),
xml.take(10).toList().joinToString("\n")
)
} |
Beta Was this translation helpful? Give feedback.
Supported since this PR: #1180
Example: