I am trying to convert a message which i receive through JMS, which is in this form "Harry PotterJ.K.Rowling1995"
我正在尝试转换我通过JMS收到的消息,其形式为“Harry PotterJ.K.Rowling1995”
This is stored as a String. For example String contents.
它存储为String。例如String内容。
How do i convert this String contents into an XML file.
如何将此String内容转换为XML文件。
Thanks you so much for your help in advance.
非常感谢你的帮助。
1 个解决方案
#1
0
Smart ass answer:String xmlString = "<myNewXmlString>" + myString + "</mynewXmlString>";
Smart ass answer:String xmlString =“
If it's more complicated you may want to look at this: http://xerces.apache.org/xerces-j/
如果它更复杂,你可能想看看这个:http://xerces.apache.org/xerces-j/
You probably also need some delimiter (a comma or colon separating the values) of the string to know What is a title, author and year. You'd then need separate tags for each. Another way to solve that is to use fixed width columns. So authors are 50, titles are 50, and years are 4. There are really three steps here: tokenizing the string, parsing the string into a data structure, and outputting the data structure to XML.
您可能还需要一些字符串的分隔符(逗号或冒号分隔值)以了解什么是标题,作者和年份。然后,您需要为每个标签分别添加标签。解决这个问题的另一种方法是使用固定宽度的列。所以作者是50,标题是50,年是4.这里有三个步骤:标记字符串,将字符串解析为数据结构,并将数据结构输出到XML。
There are lots of automated tools that can convert a data structure like this:
有很多自动化工具可以转换这样的数据结构:
class Book {
String title;
String author;
Date year;
}
into XML as well.
也是XML。
See: http://jackson-users.ning.com/profiles/blogs/experimental-support-for
#1
0
Smart ass answer:String xmlString = "<myNewXmlString>" + myString + "</mynewXmlString>";
Smart ass answer:String xmlString =“
If it's more complicated you may want to look at this: http://xerces.apache.org/xerces-j/
如果它更复杂,你可能想看看这个:http://xerces.apache.org/xerces-j/
You probably also need some delimiter (a comma or colon separating the values) of the string to know What is a title, author and year. You'd then need separate tags for each. Another way to solve that is to use fixed width columns. So authors are 50, titles are 50, and years are 4. There are really three steps here: tokenizing the string, parsing the string into a data structure, and outputting the data structure to XML.
您可能还需要一些字符串的分隔符(逗号或冒号分隔值)以了解什么是标题,作者和年份。然后,您需要为每个标签分别添加标签。解决这个问题的另一种方法是使用固定宽度的列。所以作者是50,标题是50,年是4.这里有三个步骤:标记字符串,将字符串解析为数据结构,并将数据结构输出到XML。
There are lots of automated tools that can convert a data structure like this:
有很多自动化工具可以转换这样的数据结构:
class Book {
String title;
String author;
Date year;
}
into XML as well.
也是XML。
See: http://jackson-users.ning.com/profiles/blogs/experimental-support-for