如何使用XMLBeans向XML添加XML声明 [英] How to add XML declaration to xml with XMLBeans

查看:149
本文介绍了如何使用XMLBeans向XML添加XML声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Java XMLBeans有这个问题.我想在XML文件的顶部包含以下声明:

I have this question about Java XMLBeans. I want to include the following declaration at the top of the XML file:

<?xml version="1.0" encoding="UTF-8"?>

反正有使用XMLBeans本地执行此操作吗?上面的内容始终可以作为String链接到xml内容,但这很丑.

Is there anyway to do this natively with XMLBeans? The above can always be concatenated as String to the xml content but that's ugly.

谢谢!

推荐答案

<?xml version="1.0" encoding="UTF-8"?>构造是 每个

将此源​​表示的XML写入给定的SAX内容,然后 词法处理程序.请注意,此方法不会保存XML 声明,包括编码信息. 要保存XML XML声明,请参见保存(OutputStream)保存(文件)

Writes the XML represented by this source to the given SAX content and lexical handlers. Note that this method does not save the XML declaration, including the encoding information. To save the XML declaration with the XML, see save(OutputStream), save(OutputStream, XmlOptions), save(File) or save(File, XmlOptions).

这篇关于如何使用XMLBeans向XML添加XML声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆