Parsing an HTML Document - Change Relative paths to fully qualified paths 
Author Message
 Parsing an HTML Document - Change Relative paths to fully qualified paths

Hi all!

I want to parse an HTML document and change all of the relative
paths for the (<img src> <a href> <form action>) tags to fully qualified url
with the domain name.

For instance,

src="/pics/mypic.jpg"  would become
src=" http://www.*-*-*.com/ ;

This seems easy enough with the replace function, right?  For instance:

mydomain = http://www.*-*-*.com/
sHTMLDoc = replace(sHTMLDoc, "src=" & chr(34), "src=" & chr(34) & mydomain)

But, what if the src is equal to
src=" http://www.*-*-*.com/ ;
before using the Replace function?  Then I would end up with
src=" http://www.*-*-*.com/ ://"

Any ideas or suggestions on how to attack this would be highly
appreciated...  Thanks!


Wed, 17 Apr 2002 03:00:00 GMT  
 Parsing an HTML Document - Change Relative paths to fully qualified paths
If you know that the relative path will always have a preceding delimiter
(\), then you can simly modify your code like this...

mydomain =
sHTMLDoc = replace(sHTMLDoc, "src=" & chr(34) & "\", "src=" & chr(34) &
mydomain & "\")

This way, if the link is not relative, then no replacement will be made,
because the delimiter won't follow immediately after the quotation marks in
a full address.  If is IS a relative address, then the shaved off delimiter
will simply be replaced when the preceeding part of the absolute address is

Wed, 17 Apr 2002 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Creating relative directory path given fully-qualified path

2. Getting filename out of fully qualified path

3. Best method of determining path, relative path and/or flie name

4. convert absolut path to relative path

5. ? How do you change a path to a dos path name

6. Changing Long Paths to Short Paths in a 16-bit App

7. Changing active document path

8. Change My Documents Path With VBScript

9. Flexible or relative path for import

10. Error trying to set relative path on linked powerpoint presentation

11. I want absolute path in hyperlinks and linked pitures (word makes them relative)

12. Relative Path to Access DB in VB.NET


Powered by phpBB® Forum Software