Closed H2RockyRoad closed 4 years ago
We did some investigating and it appears it is the function escapeValue that takes our xml and turns it into the escape codes for "<" and ">" symbols. How can we avoid "re-escaping" xml?
From what I can gather, it sounds like you are appending children to the document as text elements. That's why they are being escaped.
If you could re-paste your example code using the "insert code" button, it will help me understand what the exact issue is.
Is there a way to append children not as text elements?
Here's the code re-paste
"FeatureList" { val parentFeatures = featureList?.filter { feature -> feature.size == 1 } parentFeatures?.forEach { feature -> var featureXml = createFeatureXml(feature) -featureXml } }
fun createFeatureXml(feature): Node { return xml("Feature") { "Code" { -feature.code } "ValueList" { "Value" { -(feature.value ?: "") } } } }
Thanks
You can use addNode
to append children.
"FeatureList" {
val parentFeatures = featureList?.filter { feature -> feature.size == 1 }
parentFeatures?.forEach { feature ->
var featureXml = createFeatureXml(feature)
addNode(featureXml)
}
}
Awesome, Thank you!
We have implemented the Kotlin XML Builder. We are running into an issue when we need to loop 1 to n times on a xml section. We are calling a function to return what we need: We created a kotlin function called createFeature, but when we get a response and attempt to use it, the greater than and less than symbols are encoded (i.e. ">" becomes >)
Our code looks like this: xml("Root"){ "FeatureList { myFunction(myParameters) }
fun myFunction (myParameters: Parameter): Node { return xml("Feature") { "Code" { -myParameters.code} } }
We confirm the output of myFunction is
But when we take that result and output it under, we get the encoding:
Any ideas?
UPDATE: We noticed when this posted it took the encoding and actually turned it into greater than and less than symbols. Hopefully you know what we are talking about.