Hi guys , i'm new here and this in my first post!
I'm here because i'd like to share with you a small project i realized for my business due the difficult and boilerplate Scala XML library's API.
This project is vert young and simple. It's based on Cats-core using MonadError in to handle errors.
I hope that someone can contribute to it.
- Append, Remove, Replace XML nodes
- Edit node's attributes
- Read XML handling optionality and mandatory nodes and attributes
- Convert XML into Object and viceversa
- Normalize XML
- Convert Java Document to Scala NodeSeq
import com.github.geirolz.advxml.all._ import scala.xml._ import scala.util._ //import MonadError instance for Try import cats.instances.try_._ val doc: Elem = <Persons> <Person Name="Mimmo"> <Cars> <Car Brand="Fiat"/> </Cars> </Person> </Persons> val rule = $(_ \ "Person" \ "Cars") ==> Append(<Car Brand="Lamborghini"/>) ==> Append(<Car Brand="Ferrari"/>) ==> Append(<Car Brand="Bmw"/>) val result: Try[NodeSeq] = doc.transform[Try](rule)
I hope this small project can help someone in desperation with Scala XML library
Let me know what you think about it :)