首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用“image:image”创建XML元素

使用“image:image”创建XML元素
EN

Stack Overflow用户
提问于 2013-04-09 19:38:15
回答 2查看 281关注 0票数 1

我正在使用java创建一个sitemap xml。

代码语言:javascript
运行
复制
Element img = doc.createElement("image:image");

我得到了一个异常:

代码语言:javascript
运行
复制
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.

关于如何创建元素有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2013-04-09 19:58:45

我认为您应该使用XML名称空间。有关如何做到这一点,请参阅此问题:Creating an XML document using namespaces in Java

票数 1
EN

Stack Overflow用户

发布于 2013-04-09 19:51:15

在此元素名称"image:image"中,此:不是有效的编写器。

编辑

Reference link

代码语言:javascript
运行
复制
Best Naming Practices for XML Element Name

Make names descriptive. Names with an underscore separator are nice: <first_name>, <last_name>.

Names should be short and simple, like this: <book_title> not like this: <the_title_of_the_book>.

Avoid "-" characters. If you name something "first-name," some software may think you want to subtract name from first.

Avoid "." characters. If you name something "first.name," some software may think that "name" is a property of the object "first."

Avoid ":" characters. Colons are reserved to be used for something called namespaces (more later).

XML documents often have a corresponding database. A good practice is to use the naming rules of your database for the elements in the XML documents.

Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15900829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档