|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP and XML problem
I'm trying to use ASP to write XML documents form input from a HTML form. I have to write some tags like this: <creation audience="internal">Written in <date>[input from form: yyyy]</date>by using guideline <title>[input from form]</title>and reviewed by <employee>[input from form]</employee>on <date>[input from form: mm/dd/yy]</date> </creation> It's the standard text that has to go between the tags (from the second one onwards) that's giving me a headache. I've tried to solve this by the following code, but the 'Response.Write's' won't do the trick: Set objChildCreation = objDom.createElement("creation") objChildReviewdesc.appendChild objChildCreation objChildCreation.setAttributeNode objattCreationAudience objattCreationAudience.Text="internal" objChildCreation.Text = "Written in" Set objChildCreation1Date = objDom.createElement("date") objChildCreation.appendChild objChildCreation1Date objChildCreation1Date.Text = Request.Form("firstdate") Response.Write (" by using guideline ") Set objChildCreationTitle = objDom.createElement("title") objChildCreation.appendChild objChildCreationTitle objChildCreationTitle.Text=Request.Form("title") Response.Write (" and reviewed by ") Set objChildCreationEmployee = objDom.createElement("employee") objChildCreation.appendChild objChildCreationEmployee objChildCreationEmployee.Text=Request.Form("employee") Response.Write (" on ") Set objChildCreation2Date = objDom.createElement("date") objChildCreation.appendChild objChildCreation2Date objChildCreation2Date.Text = Request.Form("seconddate") Any help would be appreciated, TIA W. w@m wrote:
Show quote > Hi, You need to use either the CreateNode method - > > I'm trying to use ASP to write XML documents form input from a HTML > form. I have to write some tags like this: > > > <creation audience="internal">Written in > <date>[input from form: yyyy]</date>by using guideline > <title>[input from form]</title>and reviewed by > <employee>[input from form]</employee>on > <date>[input from form: mm/dd/yy]</date> > </creation> > > It's the standard text that has to go between the tags (from the > second one onwards) that's giving me a headache. > I've tried to solve this by the following code, but the > 'Response.Write's' won't do the trick: > http://msdn.microsoft.com/library/en-us/xmlsdk/html/5bba501f-65c9-4d30-a555-afb325a6fc84.asp or, more simply, the createTextNode method - http://msdn.microsoft.com/library/en-us/xmlsdk/html/c5d24b30-8522-4586-9287-93971eb664fe.asp > setAttribute is simpler - > Set objChildCreation = objDom.createElement("creation") > objChildReviewdesc.appendChild objChildCreation > objChildCreation.setAttributeNode objattCreationAudience > objattCreationAudience.Text="internal" http://msdn.microsoft.com/library/en-us/xmlsdk/html/1defea0d-6b6e-48da-80b6-3a75a49123bb.asp objChildCreation.setAttribute "audience", "internal" > objChildCreation.Text = "Written in" You really should validate user inputs ...> > Set objChildCreation1Date = objDom.createElement("date") > objChildCreation.appendChild objChildCreation1Date > objChildCreation1Date.Text = Request.Form("firstdate") > Set objTextNode = objDom.createTextNode(" by using guideline ")> Response.Write (" by using guideline ") objChildCreation.appendChild objTextNode -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" Hi Bob,
Thanks a lot, that works just fine; also thanks for pointing me at a more efficient way of dealing with attributes; but what do you mean by "you really should validate user inputs"? In addition to this: is it possible to make 'if-then-else' constructions when generating xml documents like this? I mean: I also have to tag like this: <langusage>This finding aid is in <language langcode="dut" scriptcode="latn">Dutch</language> </langusage> At the moment I use three comboboxes on the input form to generate the two attribute values and the tag value itself, but off course it would be much easier to just ask for the language (Dutch or English or French) and depending on this user input fill the values of the attributes accordingly. Again: thanks in advance for any assistence, W. Show quote "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht news:ee1f06tkGHA.1204@TK2MSFTNGP02.phx.gbl... > w@m wrote: >> Hi, >> >> I'm trying to use ASP to write XML documents form input from a HTML >> form. I have to write some tags like this: >> >> >> <creation audience="internal">Written in >> <date>[input from form: yyyy]</date>by using guideline >> <title>[input from form]</title>and reviewed by >> <employee>[input from form]</employee>on >> <date>[input from form: mm/dd/yy]</date> >> </creation> >> >> It's the standard text that has to go between the tags (from the >> second one onwards) that's giving me a headache. >> I've tried to solve this by the following code, but the >> 'Response.Write's' won't do the trick: >> > You need to use either the CreateNode method - > http://msdn.microsoft.com/library/en-us/xmlsdk/html/5bba501f-65c9-4d30-a555-afb325a6fc84.asp > or, more simply, the createTextNode method - > http://msdn.microsoft.com/library/en-us/xmlsdk/html/c5d24b30-8522-4586-9287-93971eb664fe.asp >> >> Set objChildCreation = objDom.createElement("creation") >> objChildReviewdesc.appendChild objChildCreation >> objChildCreation.setAttributeNode objattCreationAudience >> objattCreationAudience.Text="internal" > > setAttribute is simpler - > http://msdn.microsoft.com/library/en-us/xmlsdk/html/1defea0d-6b6e-48da-80b6-3a75a49123bb.asp > > objChildCreation.setAttribute "audience", "internal" > >> objChildCreation.Text = "Written in" >> >> Set objChildCreation1Date = objDom.createElement("date") >> objChildCreation.appendChild objChildCreation1Date >> objChildCreation1Date.Text = Request.Form("firstdate") > > You really should validate user inputs ... > >> >> Response.Write (" by using guideline ") > > Set objTextNode = objDom.createTextNode(" by using guideline ") > objChildCreation.appendChild objTextNode > > -- > Microsoft MVP - ASP/ASP.NET > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > w@m wrote:
> Hi Bob, Never trust user inputs. Hackers love sites where no server-side validation > > Thanks a lot, that works just fine; also thanks for pointing me at a > more efficient way of dealing with attributes; but what do you mean by > "you > really should validate user inputs"? of inputs is done. Never assume that client-side validation was even done. Never assume that your form controls were even used. You should make sure the inputs contain what they are supposed to contain, and only what they are supposed to contain. Show quote > Of course. Why wouldn't it be possible? However, this sounds like a good > In addition to this: is it possible to make 'if-then-else' > constructions when generating xml documents like this? I mean: I also have > to tag > like this: > > <langusage>This finding aid is in > <language langcode="dut" scriptcode="latn">Dutch</language> > </langusage> > > At the moment I use three comboboxes on the input form to generate > the two attribute values and the tag value itself, but off course it would > be > much easier to just ask for the language (Dutch or English or French) and > depending on this user input fill the values of the attributes > accordingly. place for an array, rather than if ... else: <select name="lang"> <option value=0>Dutch <option value=1>English <option value=2>French </select> <% dim arLang(2,2) arLang(0,0)="dut" arLang(1,0)="latn" arLang(2,0)="Dutch" dim arLang(2,2) arLang(0,1)="eng" arLang(1,1)="latn" arLang(2,1)="English" dim arLang(2,2) arLang(0,2)="fre" arLang(1,2)="latn" arLang(2,2)="French" dim lang lang=cint(request.form("lang")) .... objLangNode.setAttribute "langcode".arLang(0,lang) objLangNode.setAttribute "scriptcode".arLang(1,lang) objLangNode.Text=arLang(2,lang) -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM" Hi Bob,
I tried this, but it returns an error: arLang is defined more than once. Regards, W. Show quote "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht news:ugewx0wkGHA.836@TK2MSFTNGP02.phx.gbl... > w@m wrote: >> Hi Bob, >> >> Thanks a lot, that works just fine; also thanks for pointing me at a >> more efficient way of dealing with attributes; but what do you mean by >> "you >> really should validate user inputs"? > > Never trust user inputs. Hackers love sites where no server-side > validation of inputs is done. Never assume that client-side validation was > even done. Never assume that your form controls were even used. > > You should make sure the inputs contain what they are supposed to contain, > and only what they are supposed to contain. > >> >> In addition to this: is it possible to make 'if-then-else' >> constructions when generating xml documents like this? I mean: I also >> have to tag >> like this: >> >> <langusage>This finding aid is in >> <language langcode="dut" scriptcode="latn">Dutch</language> >> </langusage> >> >> At the moment I use three comboboxes on the input form to generate >> the two attribute values and the tag value itself, but off course it >> would be >> much easier to just ask for the language (Dutch or English or French) and >> depending on this user input fill the values of the attributes >> accordingly. > > Of course. Why wouldn't it be possible? However, this sounds like a good > place for an array, rather than if ... else: > > > <select name="lang"> > <option value=0>Dutch > <option value=1>English > <option value=2>French > </select> > > > <% > dim arLang(2,2) > arLang(0,0)="dut" > arLang(1,0)="latn" > arLang(2,0)="Dutch" > dim arLang(2,2) > arLang(0,1)="eng" > arLang(1,1)="latn" > arLang(2,1)="English" > dim arLang(2,2) > arLang(0,2)="fre" > arLang(1,2)="latn" > arLang(2,2)="French" > > dim lang > lang=cint(request.form("lang")) > ... > > objLangNode.setAttribute "langcode".arLang(0,lang) > objLangNode.setAttribute "scriptcode".arLang(1,lang) > objLangNode.Text=arLang(2,lang) > > > > -- > Microsoft MVP - ASP/ASP.NET > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > w@m wrote:
> Hi Bob, Yep. I goofed. Get rid of the second "dim arlang(2,2)" statement. I was> > I tried this, but it returns an error: arLang is defined more than > once. > doing some copying and pasting for this and objviously copied one line too many ... Show quote >> <% >> dim arLang(2,2) >> arLang(0,0)="dut" >> arLang(1,0)="latn" >> arLang(2,0)="Dutch" >> dim arLang(2,2) >> arLang(0,1)="eng" >> arLang(1,1)="latn" >> arLang(2,1)="English" >> dim arLang(2,2) <<<-------------delete this! >> arLang(0,2)="fre" >> arLang(1,2)="latn" >> arLang(2,2)="French" >> >> dim lang >> lang=cint(request.form("lang")) >> ... >> >> objLangNode.setAttribute "langcode".arLang(0,lang) >> objLangNode.setAttribute "scriptcode".arLang(1,lang) >> objLangNode.Text=arLang(2,lang) >> >> >> >> -- >> Microsoft MVP - ASP/ASP.NET >> Please reply to the newsgroup. This email account is my spam trap so >> I don't check it very often. If you must reply off-line, then remove >> the "NO SPAM" -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup. Hi Bob,
Sorry, but that doesn't work either, so I decided to give an if..then..else-construction a try and that works fine. Regards, W. Show quote "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht news:ezkZI19kGHA.4888@TK2MSFTNGP02.phx.gbl... > w@m wrote: >> Hi Bob, >> >> I tried this, but it returns an error: arLang is defined more than >> once. >> > > Yep. I goofed. Get rid of the second "dim arlang(2,2)" statement. I was > doing some copying and pasting for this and objviously copied one line > too many ... > > >>> <% >>> dim arLang(2,2) >>> arLang(0,0)="dut" >>> arLang(1,0)="latn" >>> arLang(2,0)="Dutch" >>> dim arLang(2,2) >>> arLang(0,1)="eng" >>> arLang(1,1)="latn" >>> arLang(2,1)="English" >>> dim arLang(2,2) <<<-------------delete this! >>> arLang(0,2)="fre" >>> arLang(1,2)="latn" >>> arLang(2,2)="French" >>> >>> dim lang >>> lang=cint(request.form("lang")) >>> ... >>> >>> objLangNode.setAttribute "langcode".arLang(0,lang) >>> objLangNode.setAttribute "scriptcode".arLang(1,lang) >>> objLangNode.Text=arLang(2,lang) >>> >>> >>> >>> -- >>> Microsoft MVP - ASP/ASP.NET >>> Please reply to the newsgroup. This email account is my spam trap so >>> I don't check it very often. If you must reply off-line, then remove >>> the "NO SPAM" > > -- > Microsoft MVP -- ASP/ASP.NET > Please reply to the newsgroup. The email account listed in my From > header is my spam trap, so I don't check it very often. You will get a > quicker response by posting to the newsgroup. > > w@m wrote:
> Hi Bob, What was the symptom?? "doesn't work" doesn't work.> > Sorry, but that doesn't work either, > so I decided to give an It's your app ...> if..then..else-construction a try and that works fine. > I just spotted another problem. I mistakenly typed periods where i should have typed commas: >> objLangNode.setAttribute "langcode".arLang(0,lang) should be>> objLangNode.setAttribute "scriptcode".arLang(1,lang) objLangNode.setAttribute "langcode",arLang(0,lang) objLangNode.setAttribute "scriptcode",arLang(1,lang) -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup. |
|||||||||||||||||||||||