Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem Loading XML file with % sign

5 views
Skip to first unread message

Padmanabhan Karatha

unread,
Apr 4, 2003, 1:40:34 PM4/4/03
to
Hi,

I am trying to load a file with % sign in it.

eg: "style.personalmonitoring viewsmonitoringview%2512.772485138".

I am using the following code in VB to do that:

Dim XMLDoc As New DOMDocument

Set readXMLFile = Nothing
If Len(strFilename) <= 0 Or Len(Dir(strFilename, vbNormal)) <= 0 Then
Exit Function
If Not XMLDoc.Load(strFilename) Then Exit Function
Set readXMLFile = XMLDoc.documentElement

I am getting the following error when I do that:

"The system cannot locate the resource specified."

Readystate : 4
Error code : -2146697211

It works fine with all other file names with special characters.

Is there any reason why Load does not accept file names with % in it?

Your help will be much appreciated.

Regards,
Padmanabhan


Mike Sharp

unread,
Apr 4, 2003, 2:01:56 PM4/4/03
to
I imagine it's interpreting the %25 as a URL-encoded %. I assume the
numeric data after viewsmonitoringview% is supposed to be "2512.772485138",
right? That is, the string begins with 25? You'll need to escape the
percent sign as like this:

style.personalmonitoring viewsmonitoringview%252512.772485138

Note the extra "25". In JScript, it's done with: escape(charString). I
don't know how its done in VB

Regards,
Mike Sharp

"Padmanabhan Karatha" <Padmanabh...@compuware.com> wrote in message
news:3e8dd1a3$1...@10.10.0.241...

Padmanabhan Karatha

unread,
Apr 4, 2003, 2:30:57 PM4/4/03
to
Hi, Mike,

Thanks for the reply.

I do not think that is the case. Whatever you suggested, I tested and it did
not work in VB. I did not test it in ASP sing VBScript.

Even if I use %abc(alphabets after %) instead of %25 (numbers after %), I
am getting the same issue. As you think, we also think that it has to do
with the way % is treated.

If you have more clues, or someone else has some ideas, your help is much
appreciated.

Regards,
Padmanabhan


"Mike Sharp" <rdc...@hotmail.com> wrote in message
news:b6kkr7$6eq76$1...@ID-182608.news.dfncis.de...

Mike Sharp

unread,
Apr 4, 2003, 3:04:29 PM4/4/03
to
No, you misunderstand. The server sees the percent, and expects the next
two digits to be part of a URL Encoded sequence. I pass percents on the URL
all the time. You must escape a percent to use it there. Modify your test
code like: %25abc, and it will evaluate on the server to be %abc.

Regards,
Mike Sharp


"Padmanabhan Karatha" <Padmanabh...@compuware.com> wrote in message

news:3e8ddd73$1...@10.10.0.241...

Padmanabhan Karatha

unread,
Apr 4, 2003, 4:02:01 PM4/4/03
to
Hi, Mike,

Sorry for not communicating well. I got your point and tried it. It is not
working. I use Windows2000 professional and VB6.

I tried as you suggested %25abc and it is giving the same problem.

More answers and ideas from members are welcome.

Regards,
Padmanabhan


"Mike Sharp" <rdc...@hotmail.com> wrote in message

news:b6koge$6g8uu$1...@ID-182608.news.dfncis.de...

Han

unread,
Apr 4, 2003, 11:04:02 PM4/4/03
to
Hi Padmanabhan

I could reproduce your error. e.g. "1234.1234" works while "12%34.1234"
doesn't. Funny is that filesystem just works with the odd file name. e.g.

set fso=createobject(scripting.filesytemobject")
set f.fso.opentextfile("12%34.1234")
msgbox f.readAll

WORKS. You may want /xmdoc.loadxml f.readall/.

--
Have a nice day.
Han Pohwan, Microsoft MVP(ASP), Korea

"Padmanabhan Karatha" <Padmanabh...@compuware.com> wrote in message

news:3e8df2cc$1...@10.10.0.241...

Mike Sharp

unread,
Apr 7, 2003, 7:18:10 PM4/7/03
to
well, the percent, if escaped, shouldn't be a problem--I use it frequently.
For examle, just today I wrote a query that needed to pass the percent in
the URL like:

LocDev-test/vDir/template/getStats?filename=%25&build1=6.1

This gets escaped so the querystring parameters are filename=% and
build1=6.1

It's necessary if and only if the string is used as a URL. I'm wondering if
there happen to be any backslash characters in the URL? (ie: "\" ) These
will need to be escaped if the value is stored in a string. IOW,

s = "c:\filepath\file.xml"

xmlDoc.load(s)

will not evaluate correctly. You need to escape the escape character, like:

s = "c:\\filepath\\file.xml"

If you could post a more complete example of your code, it would be helpful.

Regards,
Mike Sharp

"Padmanabhan Karatha" <Padmanabh...@compuware.com> wrote in message

news:3e8df2cc$1...@10.10.0.241...

0 new messages