Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading XML file as String is not working properly  RSS feed

 
Andrew Carney
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I am using the below code in order to read a file and convert it into a String.
When I read a text file it is fine however when i'm reading an xml file all I'm getting are the values of the XML attributes without any of the tags.
I'm assuming it has to be something with the encoding and was wondering if someone can help


 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like it's eating your new-lines.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all I'm getting are the values of the XML attributes


Exactly how are you looking at the resulting String?

Bill
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Carney wrote:When I read a text file it is fine however when i'm reading an xml file all I'm getting are the values of the XML attributes without any of the tags.


Well, an XML file is a text file so that sounds wrong right away. However "getting the values of the attributes without any of the tags" can't possibly be done by the code you posted. So perhaps you could post the input and output of that code, so we can see what you mean by that statement?
 
Andrew Carney
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think I know what is causing me this problem although still don't know how to fix it.

I wanted to keep my question simple so probably should have mentioned that the file is going through an object of type org.springframework.web.multipart.MultipartFile first (I am doing this through a Spring MVC application).
It looks like that MultipartFile is being too smart and is stripping the xml tags from the file, leaving me with just the values. I have tried with a couple of coding options and I always get the same result - From a simple standalone java application I get the content of the file correctly however when reading it through a MultipartFile object it strips the tags out. I have posted this in the springsource forum and hopefully someone will be able to help there.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!