473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

ASP and XML problem

w
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:
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("employ ee")

Response.Write (" on ")

Set objChildCreation2Date = objDom.createElement("date")
objChildCreation.appendChild objChildCreation2Date
objChildCreation2Date.Text = Request.Form("seconddate")

Any help would be appreciated,

TIA

W.

Jun 18 '06 #1
7 1423
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...b325a6fc84.asp
or, more simply, the createTextNode method -
http://msdn.microsoft.com/library/en...971eb664fe.asp
Set objChildCreation = objDom.createElement("creation")
objChildReviewdesc.appendChild objChildCreation
objChildCreation.setAttributeNode objattCreationAudience
objattCreationAudience.Text="internal"
setAttribute is simpler -
http://msdn.microsoft.com/library/en...75a49123bb.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"
Jun 18 '06 #2
w
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.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schreef in bericht
news:ee**************@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...b325a6fc84.asp
or, more simply, the createTextNode method -
http://msdn.microsoft.com/library/en...971eb664fe.asp

Set objChildCreation = objDom.createElement("creation")
objChildReviewdesc.appendChild objChildCreation
objChildCreation.setAttributeNode objattCreationAudience
objattCreationAudience.Text="internal"


setAttribute is simpler -
http://msdn.microsoft.com/library/en...75a49123bb.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"

Jun 18 '06 #3
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"
Jun 18 '06 #4
w
Hi Bob,

I tried this, but it returns an error: arLang is defined more than once.

Regards,

W.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schreef in bericht
news:ug*************@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"

Jun 19 '06 #5
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.
Jun 19 '06 #6
w
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.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schreef in bericht
news:ez**************@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.

Jun 20 '06 #7
w@m wrote:
Hi Bob,

Sorry, but that doesn't work either,
What was the symptom?? "doesn't work" doesn't work.
so I decided to give an
if..then..else-construction a try and that works fine.

It's your app ...

I just spotted another problem. I mistakenly typed periods where i
should have typed commas:
objLangNode.setAttribute "langcode".arLang(0,lang)
objLangNode.setAttribute "scriptcode".arLang(1,lang)


should be

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.
Jun 20 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.