This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Upload multiple xml files  RSS feed

 
Amy Howard
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application needs to validate XML files. Before validation, I want to know how to check the file is a XML type file. Please help me.
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your topic is "upload multiple xml files", so I assume you want to check that the file is xml before it is uploaded?
There is probably a javascript trick to do that on the client side.
Otherwise, if you have already uploaded the file and want to check it, there are a couple of things you can do.
First, look at the file extension. Not ".xml"? Probably not what you want.
Second, grab the first line out of the file. If it isn't an xml declaration, you probably don't want it.
Of course, validating the file will tell you right away if it valid xml or not...
 
Amy Howard
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response. The reason I need to check the file type is that the user may upload files type with img, and the textarea can't display this type file. Javascript is a good solution. Can you provide the code?
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm....
I've never done that, so we probably need this thread moved over to the HTML/Javascript forum.
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amy, I'm using jspsmartupload to upload files to my server. I can restrict the files extensions I want to upload. for example:
mySmartUpload.setAllowedFilesList("xml,XML");
you can also use the oreilly classes developed by jason hunter. These classes give you the same functionality.
hope it helps
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andres, that product is very, very, very cool.
Amy, looks like you've got a great solution here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!