Conversion of XML to ASCII... Easy?
Conversion of XML to ASCII... Easy?
Author
Discussion

ProPlus

Original Poster:

3,810 posts

270 months

Tuesday 21st February 2006
quotequote all
How easy for it to do the conversion above??

It could be in JAVA or in C++.

I would prefer to do a JAVA version of it.

dilbert

7,741 posts

261 months

Tuesday 21st February 2006
quotequote all
ProPlus said:
How easy for it to do the conversion above??

It could be in JAVA or in C++.

I would prefer to do a JAVA version of it.


XML is usually ASCII.

ProPlus

Original Poster:

3,810 posts

270 months

Tuesday 21st February 2006
quotequote all
dilbert said:
ProPlus said:
How easy for it to do the conversion above??

It could be in JAVA or in C++.

I would prefer to do a JAVA version of it.


XML is usually ASCII.


the xml is coming to us in one format, I then need to convert it to a base version of ASCII so online reports can be produced, without anyone knowing there have been changes.

jamieboy

5,929 posts

259 months

Tuesday 21st February 2006
quotequote all
I'm with Dilbert...

Are you wanting to translate an XML file to (say) a .CSV file that you could import into Excel, or something like that?

dilbert

7,741 posts

261 months

Tuesday 21st February 2006
quotequote all
Still none the wiser.....


Theres an XML parser in one of the standard java libraries, IIRC.

Have a nose through the manual, javax.xml.parsers.

Hope that helps.

ProPlus

Original Poster:

3,810 posts

270 months

Tuesday 21st February 2006
quotequote all
was thinking that the possible route would be to take the XML and using XSLT, a specfic style sheet for each xml I could produce pure ASCII as the output.

>> Edited by ProPlus on Tuesday 21st February 16:06

gannmaster

69 posts

278 months

Tuesday 21st February 2006
quotequote all
ProPlus said:
How easy for it to do the conversion above??

It could be in JAVA or in C++.

I would prefer to do a JAVA version of it.


Your comments don't give much away about the project but it seems that what you're trying to do is deserialize the XML, and then serialize it again in a different format i.e. ASCII...

Depending on how complex the document is it could be something as simple as defining a class that matches the data in the XML doc, deserializing that doc into an object of the defined class, then re-serializing it (presumably with formatting) in ASCII... at least that would be my general approach

I just googled for Java XML reader and got tons of links....



pdV6

16,442 posts

291 months

Tuesday 21st February 2006
quotequote all
^ Wot he said.

XML is just a structured way of organising data. The files themselves are just ASCII.

XSLT sounds like the easiest way of doing what (I presume) you want

zaktoo

1,401 posts

270 months

Tuesday 21st February 2006
quotequote all
Although XSLT isn't really easy it may be your quickest solution. XSLT seems to have been written by a bunch of escapees from a mental institution whilst they were high on a combnation of crack and acid. It is probably exactly what you're needing here though...

Ciao

Zak

oldskool

317 posts

260 months

Tuesday 21st February 2006
quotequote all
XML documents can be encoded in a number of formats - ascii, UTF-8, UTF-16 etc. Its normally specified in the header. The default is UTF-8, eg.

<?xml version="1.0" encoding="UTF-8" ?>

Sounds like Proplus just wants to convert the whole document to ascii, rather than parse the attributes/tags within it... First you need to find out what encoding your documents are in - they could already be ascii?

robdickinson

31,343 posts

284 months

Tuesday 21st February 2006
quotequote all
You can use dom/jdom to load the xml doc in java and run through the structure doing clevver stuff or just plain to text/ascii stuff but that sounds like overkill.

anonymous-user

84 months

Wednesday 22nd February 2006
quotequote all
oldskool said:
Sounds like Proplus just wants to convert the whole document to ascii, rather than parse the attributes/tags within it... First you need to find out what encoding your documents are in - they could already be ascii?
In that case: http://javaalmanac.com/egs/java.nio.c