XML Parser with multi valued
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.
精彩评论