开发者

XML Parser with multi valued

开发者 https://www.devze.com 2023-03-08 07:09 出处:网络
I need to parse an XML in java which contains multi valued attributes. with delimiters, first value if delimited by \",\" comma then second value is delimited by \";\" semi colon, third value is delim

I need to parse an XML in java which contains multi valued attributes. with delimiters, first value if delimited by "," comma then second value is delimited by ";" semi colon, third value is delimited by * star sign, and put the values inside the arraylist

SAMPLE XML

<ab:AttributeValue>name:may, age=23; sex:m*n开发者_开发技巧ame:june, age=24;sex:m</ab:AttributeValue>

can anybody help me to write an algorithm in java for the above?


From an XML standpoint, the data in there is just ordinary 'Text'. Any java/XML toolkit, such as XMLBeans, or JAX-B, or for that matter STaX or SAX or the DOM, will just deliver it as a string. (Or as pieces of a char[]).

It's up to you to parse it; it's nothing to do with XML. You could just write ordinary Java code, or write a lexer with a package such as javacc or even ANTLR.

Me, I'd just use StaX and then write old-fashioned code that used String.split(",") and then for the ":", assuming that you don't have to worry about escaped commands and colons.

0

精彩评论

暂无评论...
验证码 换一张
取 消