Solved

how convert html form to xml using asp

Posted on 2008-10-15
6
1,075 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
Comment Utility
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
Comment Utility
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
Comment Utility
I get an error to this line

set htmlToXml = Server.CreateObject("Chilkat.HtmlToXml")
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 5

Expert Comment

by:nkoriginal
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now