Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Text File Manipulation


Message #1 by geetha_hari@h... on Fri, 26 Jul 2002 13:22:04
I have to create a FAQ on Asp, store it in a text file and display it in 
the html page. The faq might have scripting code also. Can any one suggest 
a method to do this.
I have html tags in the text file.. which will highlight the question, 
give a different color to answer and so on apart from the answer having a 
few lines of code. Server.htmlencode doesn't work for that. 
Help please
Message #2 by "phil griffiths" <pgtips@m...> on Mon, 29 Jul 2002 08:50:07
Why don't you store it in XML (which is, after all, just text) and then 
use XSLT to produce the output you need.  Its the trendy thing to do, and 
also fits your case v nicely :-)

Phil
> I have to create a FAQ on Asp, store it in a text file and display it in 
t> he html page. The faq might have scripting code also. Can any one 
suggest 
a>  method to do this.
I>  have html tags in the text file.. which will highlight the question, 
g> ive a different color to answer and so on apart from the answer having 
a 
f> ew lines of code. Server.htmlencode doesn't work for that. 
H> elp please
Message #3 by geetha_hari@h... on Tue, 30 Jul 2002 09:10:14
I had tried XML too. The problem is if a few lines of asp/html code exists 
in the answer or the question, it does not get displayed.


> Why don't you store it in XML (which is, after all, just text) and then 
u> se XSLT to produce the output you need.  Its the trendy thing to do, 
and 
a> lso fits your case v nicely :-)

> Phil
>>  I have to create a FAQ on Asp, store it in a text file and display it 
in 
t> > he html page. The faq might have scripting code also. Can any one 
s> uggest 
a> >  method to do this.
I> >  have html tags in the text file.. which will highlight the question, 
g> > ive a different color to answer and so on apart from the answer 
having 
a>  
f> > ew lines of code. Server.htmlencode doesn't work for that. 
H> > elp please
Message #4 by "Tom Zhang" <tzhang@p...> on Tue, 30 Jul 2002 13:30:09
If I understand you clearly, you are trying to display empty lines in a 
text file on to html page. The empty lines in the text file are carriage 
return and line feed (vbCrlf or chr(13) & chr(10) - might be chr(10) & chr
(13), you can test out). When you display them on html, these have to be 
replaced with html tag <br>: replace(mytext, vbCrlf, "<br>"). Hope this 
helps.

Tom



> I had tried XML too. The problem is if a few lines of asp/html code 
exists 
i> n the answer or the question, it does not get displayed.

> 
>>  Why don't you store it in XML (which is, after all, just text) and 
then 
u> > se XSLT to produce the output you need.  Its the trendy thing to do, 
a> nd 
a> > lso fits your case v nicely :-)

> > Phil
>> >  I have to create a FAQ on Asp, store it in a text file and display 
it 
i> n 
t> > > he html page. The faq might have scripting code also. Can any one 
s> > uggest 
a> > >  method to do this.
I> > >  have html tags in the text file.. which will highlight the 
question, 
g> > > ive a different color to answer and so on apart from the answer 
h> aving 
a> >  
f> > > ew lines of code. Server.htmlencode doesn't work for that. 
H> > > elp please
Message #5 by "Tom Zhang" <tzhang@p...> on Tue, 30 Jul 2002 13:39:19
I certainly misread your question. Please ignore this message. Thanks,

> If I understand you clearly, you are trying to display empty lines in a 
t> ext file on to html page. The empty lines in the text file are carriage 
r> eturn and line feed (vbCrlf or chr(13) & chr(10) - might be chr(10) & 
chr
(> 13), you can test out). When you display them on html, these have to be 
r> eplaced with html tag <br>: replace(mytext, vbCrlf, "<br>"). Hope this 
h> elps.

> Tom

> 

> > I had tried XML too. The problem is if a few lines of asp/html code 
e> xists 
i> > n the answer or the question, it does not get displayed.

> > 
>> >  Why don't you store it in XML (which is, after all, just text) and 
t> hen 
u> > > se XSLT to produce the output you need.  Its the trendy thing to 
do, 
a> > nd 
a> > > lso fits your case v nicely :-)

> > > Phil
>> > >  I have to create a FAQ on Asp, store it in a text file and display 
i> t 
i> > n 
t> > > > he html page. The faq might have scripting code also. Can any one 
s> > > uggest 
a> > > >  method to do this.
I> > > >  have html tags in the text file.. which will highlight the 
q> uestion, 
g> > > > ive a different color to answer and so on apart from the answer 
h> > aving 
a> > >  
f> > > > ew lines of code. Server.htmlencode doesn't work for that. 
H> > > > elp please
Message #6 by "TomMallard" <mallard@s...> on Tue, 30 Jul 2002 06:02:51 -0700
Then you need to convert things like "<" to "&lt;" and so on before trying
to display it...usually this isn't too hard to do with a function call.

tom mallard
seattle

-----Original Message-----
From: geetha_hari@h... [mailto:geetha_hari@h...]
Sent: Tuesday, July 30, 2002 9:10 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: Text File Manipulation


I had tried XML too. The problem is if a few lines of asp/html code exists
in the answer or the question, it does not get displayed.


> Why don't you store it in XML (which is, after all, just text) and then
u> se XSLT to produce the output you need.  Its the trendy thing to do,
and
a> lso fits your case v nicely :-)

> Phil
>>  I have to create a FAQ on Asp, store it in a text file and display it
in
t> > he html page. The faq might have scripting code also. Can any one
s> uggest
a> >  method to do this.
I> >  have html tags in the text file.. which will highlight the question,
g> > ive a different color to answer and so on apart from the answer
having
a>
f> > ew lines of code. Server.htmlencode doesn't work for that.
H> > elp please

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #7 by "phil griffiths" <pgtips@m...> on Tue, 30 Jul 2002 15:23:24
In that case you need to wrap the Q's and A's in a CDATA section within 
your XML to prevent the text being interpreted as markup.  Like this:
<document>
<question><![CDATA[what attributes can <base> tag have?]]></question>
<answer><![CDATA[<base> tag have can have href, id & target.]]></answer>
</document>

Just try it with a simple xslt like this and you'll see it displays just 
fine when converted to html:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html><head></head><body>
    <xsl:apply-templates/>
  </body></html>
</xsl:template>

<xsl:template match="question">
  <strong>Q.
    <xsl:value-of select="."/>
  </strong><br/>
</xsl:template>

<xsl:template match="answer">
  A. 
    <xsl:value-of select="."/>
  <br/>
</xsl:template>

</xsl:stylesheet>

HTH
Phil

> I had tried XML too. The problem is if a few lines of asp/html code 
exists 
i> n the answer or the question, it does not get displayed.

> 
>>  Why don't you store it in XML (which is, after all, just text) and 
then 
u> > se XSLT to produce the output you need.  Its the trendy thing to do, 
a> nd 
a> > lso fits your case v nicely :-)

> > Phil
>> >  I have to create a FAQ on Asp, store it in a text file and display 
it 
i> n 
t> > > he html page. The faq might have scripting code also. Can any one 
s> > uggest 
a> > >  method to do this.
I> > >  have html tags in the text file.. which will highlight the 
question, 
g> > > ive a different color to answer and so on apart from the answer 
h> aving 
a> >  
f> > > ew lines of code. Server.htmlencode doesn't work for that. 
H> > > elp please

  Return to Index