We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › XMLElement load file from outside of data
Page Index Toggle Pages: 1
XMLElement load file from outside of data (Read 1021 times)
XMLElement load file from outside of data
Feb 4th, 2010, 10:07am
 
Make yourself an XML file!
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<a>
   <b/>
</a>


On Windows:
Code:
XMLElement test = new XMLElement(this, "C:\TEST.xml"); 


...doesn't work. Instead, you have to replace the forward slash with a back slash like so...
Code:
XMLElement test = new XMLElement(this, "C:/TEST.xml"); 


...which is weird.
Re: XMLElement load file from outside of data
Reply #1 - Feb 4th, 2010, 10:26am
 
> XMLElement test = new XMLElement(this, "C:\TEST.xml");
> ...doesn't work.

\ is considered an escape character in java, as in \n for newline. you have to escape the escape:

XMLElement test = new XMLElement(this, "C:\\TEST.xml");

(or replace with /, yes)
Re: XMLElement load file from outside of data
Reply #2 - Feb 4th, 2010, 10:32am
 
ohhhhh.. So i'll have to run a replace for "\" to "\\" on the string. Duh!
Re: XMLElement load file from outside of data
Reply #3 - Feb 4th, 2010, 10:50am
 
except you'll have to escape all those escapes in your replace statement, so \\ and \\\\. it gets messy very quickly.
Page Index Toggle Pages: 1