there are a few examples for using Anti-Xml to extract information from XML documents, but none that I could find of using Anti-Xml to create XML documents. Does Anti-Xml support creating documents, or should I use another library for this (which one?). Does anyone have an example of creating an XML document with Anti-Xml?
相关问题
- Illegal to have multiple roots (start tag in epilo
- Unusual use of the new keyword
- Get Runtime Type picked by implicit evidence
- Newtonsoft DeserializeXNode expands internal array
- how to use special characters like '<'
相关文章
- Gatling拓展插件开发,check(bodyString.saveAs("key"))怎么实现
- Creating XML Elements without namespace declaratio
- RDF libraries for Scala [closed]
- Get Attribute Value From Simple XML Using JQuery /
- Why is my Dispatching on Actors scaled down in Akk
- How do you run cucumber with Scala 2.11 and sbt 0.
- Directly signing an Office Word document using XML
- When sending XML to JMS should I use TextMessage o
Yes, you can build (and serialize) XML documents:
You can also use Anti-XML's zippers to do some interesting editing tricks:
Now
newDoc
contains the edited document:The
Zipper
thatdoc \ "foo"
returns is different from aNodeSeq
in that it carries information about its context, which allows you to "undo" the selection operation done by\
.Update in response to ziggystar's comment below: if you want something like Scala's XML literals, you can just use
convert
on anyscala.xml.Elem
:I'd assumed the question was about programmatic creation.
Unless you are using other parts of anti-xml I'd stick with Scala's literals. However if you are looking for a better alternative with a nice builder DSL, in place updates, XPath usage (DSL and String based) etc, then I'd suggest a look at Scales. From the 0.3-RC5 release site (http://scala-scales.googlecode.com/svn/sites/scales/scales-xml_2.9.1/0.3-RC5/index.html):
Also for direct serialisation you can leverage streaming, as Scales Xml model unifies the model for streaming and tree based processing.
I'm short before a 0.3-RC6 with many more docs (and very cool xml comparison framework) but I'm waiting on migrating to sonatype first. (eta next week)