[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XML parsing the only way?
> > > > The quickest code for doing this is to write a loop through > > the string, > > I see from this and your post on xsl-list that you're a man who likes > low-level coding. > No, Michael, it is not so. I am just trying to match the level of coding to the level of the problem. And, regarding the xsl-list post, I am not asking for lower-level coding; in fact, I think that coding with perl|python|ruby would be higher-level and more natural than with XSLT 2.0. > What's wrong with: > > (char)Integer.parseInt(Pattern.compile("&#([0-9]+);").matcher(bunch).gro > up(1)); > don't get me wrong, I am not trying to compete. But: 1) it only works with Java 1.4+. I simply don't have it installed on any of my computers because they are slow and it takes twice as much time to launch as 1.3. 2) it only returns the first character. The OP asked to convert a bunch to a string. 3) it does not handle literal character in the input. The code below does. If you add all these things to the single line above, you'll get as much code, only slower and running on fewer platforms. > Also untested. > > OK, add a couple more lines to do hex as well (but the OP didn't ask for > that). The code that just retrieves the first decimal character entity from a string without regexps is as short as the line above. I've just tried to provide a solution that would work. Besides, I was just reacting the idea to use DOMDoc for that purpose. David Tolpin http://davidashen.net/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|