Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how convert html form to xml using asp

Posted on 2008-10-15
6
1,082 Views
Last Modified: 2012-08-14
I need to convert several html forms to xml and I was wondering if someone in here would possibly know a way to achieve this by using asp code so the process is a little faster.

i have pasted one of the html forms that need this conversion as an example.

any help or recommendations are welcome.

thank you much.
<html>
<head><title>Enrollment Form</title>
</head>
<body>
<form method="post" action="/sendform"> 
  <h1>Enroll in Appliance Protection Plan</h1>
    <table border="0" cellpadding="3" cellspacing="0">
      <tr>
        <td width="100%" valign="bottom" align="left" colspan="2">
          <div>
            Before enrolling, please review the Terms &amp; Conditions outlined in the <a href="p012581.pdf">Appliance Protection Plan Service Guide</a> [PDF], then complete and submit the form below:</p>
          <table border="0" width="100%" cellpadding="2">
            <tr>
              <td width="100%"><b>1) Select your base plan:</b>
                <table border="0" width="90%" cellpadding="2">
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="35"><b><input type="checkbox" name="essentials_plan" value="yes" tabindex="1">Essentials
                      Plan ($15.95/month*) - Furnace, water heater, refrigerator
                      and:<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; (Check one coverage option below)</b></td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="38">
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="essentials" value="central air conditioning" tabindex="2">Central
                      air conditioning unit <b>or<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="essentials" value="clothes washer" tabindex="3"></b>Clothes
                      washer
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="35">
                      <input type="checkbox" name="heating_plan" value="yes" tabindex="4"><b>Heating
                      Plan<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; </b>($12.95/month*) - Furnace,
                      water heater, stove (including oven) and clothes dryer.<b>&nbsp;</b>
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="51">
                      <input type="checkbox" name="heating_plus_plan" value="yes" tabindex="5"><b>Heating
                      Plus Plan<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; </b>($19.95/month*) - Furnace,
                      water heater, stove (including oven), clothes dryer, and<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; annual furnace checkup*.
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="35">
                      <input type="checkbox" name="kitchen_plan" value="yes" tabindex="6"><b>Kitchen
                      Plan<br>
                      &nbsp;&nbsp;&nbsp;</b>&nbsp; ($12.95/month*) -
                      Refrigerator, stove (including oven), dishwasher and
                      microwave.
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="35">
                      <input type="checkbox" name="kitchen_laundry_plan" value="yes" tabindex="7"><b>Kitchen/Laundry
                      Plan<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; </b>($12.95/month*) -
                      Refrigerator, stove (including oven), clothes washer and
                      dryer.&nbsp;
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="118">
                      <input type="checkbox" name="total_home_plan" value="yes" tabindex="8"><b>Total
                      Home Plan<br>
                      &nbsp;&nbsp;&nbsp;</b>&nbsp; ($21.95/month*) - Furnace,
                      water heater, refrigerator, stove (including oven),
                      clothes<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; washer, clothes dryer and:<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; (Check one coverage option below)<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home" value="central air conditioning" tabindex="9">Central
                      air conditioning <b>or<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home" value="dishwasher" tabindex="10"></b>Dishwasher
                      <b>or</b><br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home" value="microwave" tabindex="11">Microwave
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="118">
                      <input type="checkbox" name="total_home_plus_plan" value="yes" tabindex="12"><b>Total
                      Home Plus<br>
                      &nbsp;&nbsp;&nbsp;</b>&nbsp; ($29.95/month*) - Furnace,
                      water heater, refrigerator, stove (including oven),
                      clothes<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; washer, clothes dryer and:<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; (Check one coverage option below)<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home_plus" value="central air conditioning" tabindex="13">Central
                      air conditioning <b>or<br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home_plus" value="dishwasher" tabindex="14"></b>Dishwasher
                      <b>or</b><br>
                      &nbsp;&nbsp;&nbsp;&nbsp; <input type="radio" name="total_home_plus" value="microwave" tabindex="15">Microwave
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2">
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="bottom" align="left" colspan="2" height="18">
                      <b>2) Add any one or more of
                      the following a la carte additions to your plan:</b>
                    </td>
                  </tr>
                  <tr>
                    <td width="50%" valign="top" align="left">
                      <b>$3.25 per item per month
                      with plan purchase*</b><br>
                      <input type="checkbox" name="325_per_item" value="water heater" tabindex="16">Water Heater<br>
                      <input type="checkbox" name="325_per_item" value="clothes washer" tabindex="17">Clothes Washer<br>
                      <input type="checkbox" name="325_per_item" value="clothes dryer" tabindex="18">Clothes Dryer<br>
                      <input type="checkbox" name="325_per_item" value="stove" tabindex="19">Stove<br>
                      <input type="checkbox" name="325_per_item" value="refrigerator" tabindex="20">Refrigerator<br>
                      <input type="checkbox" name="325_per_item" value="dishwasher" tabindex="21">Dishwasher<br>
                      <input type="checkbox" name="325_per_item" value="freezer" tabindex="22">Freezer<br>
                      <input type="checkbox" name="325_per_item" value="microwave" tabindex="23">Microwave
                    </td>
                    <td width="50%" valign="top" align="left">
                      <b>$4.25 per item per month
                      with plan purchase*</b><br>
                      <input type="checkbox" name="425_per_item" value="central air conditioning" tabindex="24">Central Air
                      Conditioning<br>
                      <input type="checkbox" name="425_per_item" value="furnace" tabindex="25">Furnace<br>
                      <b><br>
                      $8.50 per item per month with plan purchase*</b><br>
                      <input type="checkbox" name="850_per_item" value="heat pump" tabindex="26">Heat Pump
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2" height="18">
                      *Plus state &amp; local sales
                      taxes, Wisconsin residents only.
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2" height="69">
                      <b>3) Billing Preference:<br>
                      &nbsp;&nbsp;&nbsp; <input type="radio" name="billing_preference" value="monthly" tabindex="27"></b>Monthly<br>
                      &nbsp;&nbsp;&nbsp; <input type="radio" name="billing_preference" value="quarterly" tabindex="28">Quarterly<br>
                      &nbsp;&nbsp;&nbsp; <input type="radio" name="billing_preference" value="annually" tabindex="29">Annually
                      (save 10% by paying annually!)
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                      <table border="0" width="100%" cellspacing="0" cellpadding="0">
                        <tr>
                    <td valign="top" align="left" colspan="2">
                      <b>4) Customer Information:<br>
                      (* indicates fields required)
                      </b>
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      Name:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="name" size="35" tabindex="30">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      Service Address:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="service_address" size="35" tabindex="31">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      Billing Address:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="billing_address" size="35" tabindex="32">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                     City:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <font face="Arial" size="2"><input type="text" name="city" size="35" tabindex="33">
                      </font>
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      State:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="state" size="35" tabindex="34">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      Zip code:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="zip_code" size="35" tabindex="35">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      Phone:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="phone" size="35" tabindex="36">
                    </td>
                        </tr>
                        <tr>
                    <td width="16%" valign="top" align="left">
                      E-mail:*&nbsp;
                    </td>
                    <td width="84%" valign="top" align="left">
                      <input type="text" name="e_mail" size="35" tabindex="37">
                    </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <tr>
                    <td valign="top" align="left" colspan="2"><strong>5) Where did you hear about the Appliance Protection Plan?</strong>                      <br>
                      <b>&nbsp;&nbsp;&nbsp; </b>                      <select name="wheredidyouhear" id="wheredidyouhear" tabindex="38">
                        <option value="newspaper">Newspaper</option>
                        <option value="radio">Radio</option>
                        <option value="direct_mail">Direct mail</option>
                        <option value="bill_insert">Bill insert</option>
                        <option value="internet_site">Internet site</option>
                        <option value="word_of_mouth">Word of mouth</option>
                        <option value="other">Other</option>
                          </select></td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                      Comments:&nbsp;<br>
                      <textarea rows="2" name="comments" cols="46" tabindex="39"></textarea>
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                      <input type="checkbox" name="employee" value="yes" tabindex="40">An Energy employee lives in this household
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                      <input type="checkbox" name="contact_me" value="yes" tabindex="41">Please
                      have an Energy Customer Service Representative
                      contact me
                    </td>
                  </tr>
                  <tr>
                    <td width="100%" valign="top" align="left" colspan="2">
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td width="35%" valign="bottom" align="left"></td>
        <td width="65%" valign="bottom" align="left"><font size="3"><input type="submit" value="Submit"
        name="Submit" tabindex="41">&nbsp;<input type="reset" value="Cancel" name="cancel" tabindex="42"></font></td>
      </tr>
    </table>
 
<input type="hidden" name="email" value="webmaster@applianceprotectionform.com"><input type="hidden" name="recipient" value="ApplianceProtectionPlan@applianceprotectionplan.com"><input type="hidden" name="subject" value="Appliance Protection Plan Enrollment"><input type="hidden" name="required" value="name, service_address, billing_address, city, state, zip_code, phone, e_mail"><input type="hidden" name="redirect" value="http://www.domain.com/docs/groups/public/documents/pub/p014536.hcsp">
</form>
</body>
</html>

Open in new window

0
Comment
Question by:itortu
  • 3
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
nkoriginal earned 250 total points
ID: 22723577
here you have a nice explanation

http://www.15seconds.com/issue/010601.htm

is not easy to explain that's the reason I prefer to send you the link
0
 
LVL 5

Expert Comment

by:nkoriginal
ID: 22723583
here you have a short code.

Try it and let me know
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set htmlToXml = Server.CreateObject("Chilkat.HtmlToXml")
 
'  Any string argument automatically begins the 30-day trial.
success = htmlToXml.UnlockComponent("30-day trial")
If (success <> 1) Then
    Response.Write "HtmlToXml component unlock failed" & "<br>"
 
End If
 
'  Indicate the charset of the output XML we'll want.
htmlToXml.XmlCharset = "utf-8"
 
'  Set the HTML:
htmlToXml.Html = "<html><body><p>This is a test <a href=""http://www.chilkatsoft.com/"">Chilkat Software</a></body></html>"
 
'  Get the XML:
Response.Write Server.HTMLEncode( htmlToXml.ToXml()) & "<br>"
 
'  This is the output:
'  <?xml version="1.0" encoding="utf-8" ?>
' 
'  <root>
'      <html>
'          <body>
'              <p>
'                  <text>This is a test </text>
'                  <a href="http://www.chilkatsoft.com/">
'                      <text>Chilkat Software</text>
'                  </a>
'              </p>
'          </body>
'      </html>
'  </root>
 
%>
</body>
</html>

Open in new window

0
 

Author Comment

by:itortu
ID: 22724356
I get an error to this line

set htmlToXml = Server.CreateObject("Chilkat.HtmlToXml")
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 5

Expert Comment

by:nkoriginal
ID: 22724497
You need to install the Chilkat software. is a licensed software.
Always you will need to install components in the server.
Like I said before is not easy to explain.

if you want to try chilkat go to this link
http://www.example-code.com/ASP/htmlToXml_simple.asp

then you will see this link: Download Chilkat HTML-to-XML ActiveX (also includes HTML-to-PlainText conversion)
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22725852
itortu,

How valid is the html?  That will be a key to this working.  Do you mean actual xml of xhtml?  All of the code or just part of it?

ASP does not have good builtin objects or functions for working with DOM or making XML.  The expert above pointed out a site I like and I think they have the best objects to add to your server if you want to do this.  If this is meant to be a onetime conversion though then I would suggest looking at other technologies besides ASP that will do this easier and better.

One example, especially if the result will be xhtml, is HTML Tidy (http://www.ibm.com/developerworks/library/x-tiptidy.html).  That page has some info on and its use to see if it will do what you need.  There are other premade programs that could do this too.  A key will be what you need from the html file and how valid it is.  If the files are not well made then you almost have to create a custom tool/program and might be better off doing them manually if you only have a few.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22725872
itortu,

By the way ... one other example of a program to do this is http://www.xmlwrench.com/manual/convert.html .

Let me know if you have a question.

b0lsc0tt
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question