Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > XML problems reading file in another directory

Reply
Thread Tools

XML problems reading file in another directory

 
 
simon_s_li@hotmail.com
Guest
Posts: n/a
 
      10-25-2005
Hi,

I am new to XML and I am trying to read an XML file 3 directory levels
up.

In the jsp I am setting the src to "..\..\..\directory\file.xml" and
I've tried "../../../directory/file.xml". Both these methods don't
seem to be able pick the xml file up.

If I put the file in the same directory it works ok.

By the way, I cannot move the file to the same directory as lots of
other files read this file in the current directory.

Can you help?? What am I doing wrong??

Regards
Simon

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      10-25-2005
On 25 Oct 2005 03:05:43 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote, quoted or
indirectly quoted someone who said :

>In the jsp I am setting the src to "..\..\..\directory\file.xml" and
>I've tried "../../../directory/file.xml". Both these methods don't
>seem to be able pick the xml file up.


You might try dumping the CWD. You might be surprised.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      10-25-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> I am new to XML and I am trying to read an XML file 3 directory levels
> up.
>
> In the jsp I am setting the src to "..\..\..\directory\file.xml" and
> I've tried "../../../directory/file.xml". Both these methods don't
> seem to be able pick the xml file up.
>
> If I put the file in the same directory it works ok.
>
> By the way, I cannot move the file to the same directory as lots of
> other files read this file in the current directory.
>
> Can you help?? What am I doing wrong??


If I take your explanation literally, it seems like the correct path
should be "..\..\..\file.xml", as you say it's 3 directories up, not 2
directories up, and 1 directory "sideways".

Have you tried moving the file just one directory up and doing
"..\file.xml" to see if you're suffering from some sort of "off by 1" error?

Have you tried creating a file object pointing to the current directory
and programmatically going up via .getParentFile()?

- Oliver


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-26-2005
On Tue, 25 Oct 2005 21:36:44 GMT, "Oliver Wong" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

> "..\..\..\directory\file.xml"


Don't forget that in Java strings, \ has to be doubled.
and in regexes quadrupled to get a literal \.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
including one XML file in another XML file Johan XML 20 02-27-2007 04:29 PM
UnauthorizedAccessException when reading XML files (no problem when reading other file-types) blabla120@gmx.net ASP .Net 0 09-15-2006 02:08 PM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM



Advertisments