1 Replies - 228 Views - Last Post: 24 September 2013 - 08:26 PM Rate Topic: -----

#1 jayeomer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-July 10

ASP Classic XML to Table in html page

Posted 24 September 2013 - 08:19 PM

Hi I have few XML files, what I need to do is some how convert xml file to display in html table, I've been trying but can't get anywhere with it, the number of columns could be different from file to file. Could anyone please help

XML DATA
<data><variable name="id"><row><column>1</column></row><row><column>2</column></row><row><column>3</column></row><row><column>4</column></row><row><column>5</column></row><row><column>6</column></row><row><column>7</column></row><row><column>8</column></row><row><column>9</column></row><row><column>10</column></row><row><column>11</column></row><row><column>12</column></row><row><column>13</column></row><row><column>14</column></row><row><column>15</column></row><row><column>16</column></row><row><column>17</column></row><row><column>18</column></row><row><column>19</column></row><row><column>20</column></row><row><column>21</column></row><row><column>22</column></row><row><column>23</column></row><row><column>24</column></row><row><column>25</column></row><row><column>26</column></row><row><column>27</column></row><row><column>28</column></row><row><column>29</column></row><row><column>30</column></row><row><column>31</column></row><row><column>32</column></row><row><column>33</column></row><row><column>34</column></row><row><column>35</column></row><row><column>36</column></row><row><column>37</column></row><row><column>38</column></row><row><column>39</column></row><row><column>40</column></row><row><column>41</column></row><row><column>42</column></row><row><column>43</column></row><row><column>44</column></row><row><column>45</column></row><row><column>46</column></row><row><column>47</column></row><row><column>48</column></row><row><column>49</column></row><row><column>50</column></row><row><column>51</column></row><row><column>52</column></row><row><column>53</column></row><row><column>54</column></row><row><column>55</column></row><row><column>56</column></row><row><column>57</column></row><row><column>58</column></row><row><column>59</column></row><row><column>60</column></row><row><column>61</column></row><row><column>62</column></row><row><column>63</column></row><row><column>64</column></row><row><column>65</column></row><row><column>66</column></row><row><column>67</column></row><row><column>68</column></row><row><column>69</column></row></variable><variable name="states"><row><column>ALABAMA- AL</column></row><row><column>ALASKA- AK</column></row><row><column>AMERICAN SAMOA- AS</column></row><row><column>ARIZONA- AZ</column></row><row><column>ARKANSAS- AR</column></row><row><column>CALIFORNIA- CA</column></row><row><column>COLORADO- CO</column></row><row><column>CONNECTICUT- CT</column></row><row><column>DELAWARE- DE</column></row><row><column>DISTRICT OF COLUMBIA- DC</column></row><row><column>FEDERATED STATES OF MICRONESIA- FM</column></row><row><column>FLORIDA- FL</column></row><row><column>GEORGIA- GA</column></row><row><column>GUAM- GU</column></row><row><column>HAWAII- HI</column></row><row><column>IDAHO- ID</column></row><row><column>ILLINOIS- IL</column></row><row><column>INDIANA- IN</column></row><row><column>IOWA- IA</column></row><row><column>KANSAS- KS</column></row><row><column>KENTUCKY- KY</column></row><row><column>LOUISIANA- LA</column></row><row><column>MAINE- ME</column></row><row><column>MARSHALL ISLANDS- MH</column></row><row><column>MARYLAND- MD</column></row><row><column>MASSACHUSETTS- MA</column></row><row><column>MICHIGAN- MI</column></row><row><column>MILITARY AFRICA- AE</column></row><row><column>MILITARY AMERICAS- AA</column></row><row><column>MILITARY CALIFORNIA- AP</column></row><row><column>MILITARY CANADA- AE</column></row><row><column>MILITARY EUROPE- AE</column></row><row><column>MILITARY FLORIDA- AA</column></row><row><column>MILITARY MIDDLE EAST- AE</column></row><row><column>MILITARY NEW YORK- AE</column></row><row><column>MILITARY PACIFIC- AP</column></row><row><column>MINNESOTA- MN</column></row><row><column>MISSISSIPPI- MS</column></row><row><column>MISSOURI- MO</column></row><row><column>MONTANA- MT</column></row><row><column>NEBRASKA- NE</column></row><row><column>NEVADA- NV</column></row><row><column>NEW HAMPSHIRE- NH</column></row><row><column>NEW JERSEY- NJ</column></row><row><column>NEW MEXICO- NM</column></row><row><column>NEW YORK- NY</column></row><row><column>NORTH CAROLINA- NC</column></row><row><column>NORTH DAKOTA- ND</column></row><row><column>NORTHERN MARIANA ISLANDS- MP</column></row><row><column>OHIO- OH</column></row><row><column>OKLAHOMA- OK</column></row><row><column>OREGON- OR</column></row><row><column>PALAU- PW</column></row><row><column>PENNSYLVANIA- PA</column></row><row><column>PUERTO RICO- PR</column></row><row><column>RHODE ISLAND- RI</column></row><row><column>SOUTH CAROLINA- SC</column></row><row><column>SOUTH DAKOTA- SD</column></row><row><column>TENNESSEE- TN</column></row><row><column>TEXAS- TX</column></row><row><column>TRUST TERRITORIES- TT</column></row><row><column>UTAH- UT</column></row><row><column>VERMONT- VT</column></row><row><column>VIRGIN ISLANDS- VI</column></row><row><column>VIRGINIA- VA</column></row><row><column>WASHINGTON- WA</column></row><row><column>WEST VIRGINIA- WV</column></row><row><column>WISCONSIN- WI</column></row><row><column>WYOMING- WY</column></row></variable></data>


ASP CODE
<table border="1" width="100%">
<%
url = "http://localhost/xmlread/PVW4740.xml"
Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument")
xmlDOM.async = False
xmlDOM.setProperty "ServerHTTPRequest", True
xmlDOM.Load(url)
 
Set objLst = xmlDOM.getElementsByTagName("variable" )
SizeofObject = objLst.length-1
response.Write(SizeofObject&"<br><br>")


For each elem in objLst
    set childNodes = elem.childNodes
    for each node in childNodes

    	Response.Write "<tr><td>" & node.nodeName & "  =  " & node.text & "</td></tr>" & vbCrLf
    	
    next

Next
%>
</table>


OUTPUT
<table border="1" width="100%">
1<br><br><tr><td>row  =  1</td></tr>
<tr><td>row  =  2</td></tr>
<tr><td>row  =  3</td></tr>
<tr><td>row  =  4</td></tr>
<tr><td>row  =  5</td></tr>
<tr><td>row  =  6</td></tr>
<tr><td>row  =  7</td></tr>
<tr><td>row  =  8</td></tr>
<tr><td>row  =  9</td></tr>
<tr><td>row  =  10</td></tr>
<tr><td>row  =  11</td></tr>
<tr><td>row  =  12</td></tr>
<tr><td>row  =  13</td></tr>
<tr><td>row  =  14</td></tr>
<tr><td>row  =  15</td></tr>
<tr><td>row  =  16</td></tr>
<tr><td>row  =  17</td></tr>
<tr><td>row  =  18</td></tr>
<tr><td>row  =  19</td></tr>
<tr><td>row  =  20</td></tr>
<tr><td>row  =  21</td></tr>
<tr><td>row  =  22</td></tr>
<tr><td>row  =  23</td></tr>
<tr><td>row  =  24</td></tr>
<tr><td>row  =  25</td></tr>
<tr><td>row  =  26</td></tr>
<tr><td>row  =  27</td></tr>
<tr><td>row  =  28</td></tr>
<tr><td>row  =  29</td></tr>
<tr><td>row  =  30</td></tr>
<tr><td>row  =  31</td></tr>
<tr><td>row  =  32</td></tr>
<tr><td>row  =  33</td></tr>
<tr><td>row  =  34</td></tr>
<tr><td>row  =  35</td></tr>
<tr><td>row  =  36</td></tr>
<tr><td>row  =  37</td></tr>
<tr><td>row  =  38</td></tr>
<tr><td>row  =  39</td></tr>
<tr><td>row  =  40</td></tr>
<tr><td>row  =  41</td></tr>
<tr><td>row  =  42</td></tr>
<tr><td>row  =  43</td></tr>
<tr><td>row  =  44</td></tr>
<tr><td>row  =  45</td></tr>
<tr><td>row  =  46</td></tr>
<tr><td>row  =  47</td></tr>
<tr><td>row  =  48</td></tr>
<tr><td>row  =  49</td></tr>
<tr><td>row  =  50</td></tr>
<tr><td>row  =  51</td></tr>
<tr><td>row  =  52</td></tr>
<tr><td>row  =  53</td></tr>
<tr><td>row  =  54</td></tr>
<tr><td>row  =  55</td></tr>
<tr><td>row  =  56</td></tr>
<tr><td>row  =  57</td></tr>
<tr><td>row  =  58</td></tr>
<tr><td>row  =  59</td></tr>
<tr><td>row  =  60</td></tr>
<tr><td>row  =  61</td></tr>
<tr><td>row  =  62</td></tr>
<tr><td>row  =  63</td></tr>
<tr><td>row  =  64</td></tr>
<tr><td>row  =  65</td></tr>
<tr><td>row  =  66</td></tr>
<tr><td>row  =  67</td></tr>
<tr><td>row  =  68</td></tr>
<tr><td>row  =  69</td></tr>
<tr><td>row  =  ALABAMA- AL</td></tr>
<tr><td>row  =  ALASKA- AK</td></tr>
<tr><td>row  =  AMERICAN SAMOA- AS</td></tr>
<tr><td>row  =  ARIZONA- AZ</td></tr>
<tr><td>row  =  ARKANSAS- AR</td></tr>
<tr><td>row  =  CALIFORNIA- CA</td></tr>
<tr><td>row  =  COLORADO- CO</td></tr>
<tr><td>row  =  CONNECTICUT- CT</td></tr>
<tr><td>row  =  DELAWARE- DE</td></tr>
<tr><td>row  =  DISTRICT OF COLUMBIA- DC</td></tr>
<tr><td>row  =  FEDERATED STATES OF MICRONESIA- FM</td></tr>
<tr><td>row  =  FLORIDA- FL</td></tr>
<tr><td>row  =  GEORGIA- GA</td></tr>
<tr><td>row  =  GUAM- GU</td></tr>
<tr><td>row  =  HAWAII- HI</td></tr>
<tr><td>row  =  IDAHO- ID</td></tr>
<tr><td>row  =  ILLINOIS- IL</td></tr>
<tr><td>row  =  INDIANA- IN</td></tr>
<tr><td>row  =  IOWA- IA</td></tr>
<tr><td>row  =  KANSAS- KS</td></tr>
<tr><td>row  =  KENTUCKY- KY</td></tr>
<tr><td>row  =  LOUISIANA- LA</td></tr>
<tr><td>row  =  MAINE- ME</td></tr>
<tr><td>row  =  MARSHALL ISLANDS- MH</td></tr>
<tr><td>row  =  MARYLAND- MD</td></tr>
<tr><td>row  =  MASSACHUSETTS- MA</td></tr>
<tr><td>row  =  MICHIGAN- MI</td></tr>
<tr><td>row  =  MILITARY AFRICA- AE</td></tr>
<tr><td>row  =  MILITARY AMERICAS- AA</td></tr>
<tr><td>row  =  MILITARY CALIFORNIA- AP</td></tr>
<tr><td>row  =  MILITARY CANADA- AE</td></tr>
<tr><td>row  =  MILITARY EUROPE- AE</td></tr>
<tr><td>row  =  MILITARY FLORIDA- AA</td></tr>
<tr><td>row  =  MILITARY MIDDLE EAST- AE</td></tr>
<tr><td>row  =  MILITARY NEW YORK- AE</td></tr>
<tr><td>row  =  MILITARY PACIFIC- AP</td></tr>
<tr><td>row  =  MINNESOTA- MN</td></tr>
<tr><td>row  =  MISSISSIPPI- MS</td></tr>
<tr><td>row  =  MISSOURI- MO</td></tr>
<tr><td>row  =  MONTANA- MT</td></tr>
<tr><td>row  =  NEBRASKA- NE</td></tr>
<tr><td>row  =  NEVADA- NV</td></tr>
<tr><td>row  =  NEW HAMPSHIRE- NH</td></tr>
<tr><td>row  =  NEW JERSEY- NJ</td></tr>
<tr><td>row  =  NEW MEXICO- NM</td></tr>
<tr><td>row  =  NEW YORK- NY</td></tr>
<tr><td>row  =  NORTH CAROLINA- NC</td></tr>
<tr><td>row  =  NORTH DAKOTA- ND</td></tr>
<tr><td>row  =  NORTHERN MARIANA ISLANDS- MP</td></tr>
<tr><td>row  =  OHIO- OH</td></tr>
<tr><td>row  =  OKLAHOMA- OK</td></tr>
<tr><td>row  =  OREGON- OR</td></tr>
<tr><td>row  =  PALAU- PW</td></tr>
<tr><td>row  =  PENNSYLVANIA- PA</td></tr>
<tr><td>row  =  PUERTO RICO- PR</td></tr>
<tr><td>row  =  RHODE ISLAND- RI</td></tr>
<tr><td>row  =  SOUTH CAROLINA- SC</td></tr>
<tr><td>row  =  SOUTH DAKOTA- SD</td></tr>
<tr><td>row  =  TENNESSEE- TN</td></tr>
<tr><td>row  =  TEXAS- TX</td></tr>
<tr><td>row  =  TRUST TERRITORIES- TT</td></tr>
<tr><td>row  =  UTAH- UT</td></tr>
<tr><td>row  =  VERMONT- VT</td></tr>
<tr><td>row  =  VIRGIN ISLANDS- VI</td></tr>
<tr><td>row  =  VIRGINIA- VA</td></tr>
<tr><td>row  =  WASHINGTON- WA</td></tr>
<tr><td>row  =  WEST VIRGINIA- WV</td></tr>
<tr><td>row  =  WISCONSIN- WI</td></tr>
<tr><td>row  =  WYOMING- WY</td></tr>

</table>


DESIRED CODE
<table border="1"><tr><td>id</td><td>states</td></tr>
	<tr><td>row = 1</td><td>row = ALABAMA- AL</td></tr>
	<tr><td>row = 2</td><td>row = ALASKA- AK</td></tr>
	<tr><td>row = 3</td><td>row = AMERICAN SAMOA- AS</td></tr>
	<tr><td>row = 4</td><td>row = ARIZONA- AZ</td></tr>
	<tr><td>row = 5</td><td>row = ARKANSAS- AR</td></tr>
	<tr><td>row = 6</td><td>row = CALIFORNIA- CA</td></tr>
	<tr><td>row = 7</td><td>row = COLORADO- CO</td></tr>
	<tr><td>row = 8</td><td>row = CONNECTICUT- CT</td></tr>
	<tr><td>row = 9</td><td>row = DELAWARE- DE</td></tr>
	<tr><td>row = 10</td><td>row = DISTRICT OF COLUMBIA- DC</td></tr>
	<tr><td>row = 11</td><td>row = FEDERATED STATES OF MICRONESIA- FM</td></tr>
	<tr><td>row = 12</td><td>row = FLORIDA- FL</td></tr>
	<tr><td>row = 13</td><td>row = GEORGIA- GA</td></tr>
	<tr><td>row = 14</td><td>row = GUAM- GU</td></tr>
	<tr><td>row = 15</td><td>row = HAWAII- HI</td></tr>
	<tr><td>row = 16</td><td>row = IDAHO- ID</td></tr>
	<tr><td>row = 17</td><td>row = ILLINOIS- IL</td></tr>
	<tr><td>row = 18</td><td>row = INDIANA- IN</td></tr>
	<tr><td>row = 19</td><td>row = IOWA- IA</td></tr>
	<tr><td>row = 20</td><td>row = KANSAS- KS</td></tr>
	<tr><td>row = 21</td><td>row = KENTUCKY- KY</td></tr>
	<tr><td>row = 22</td><td>row = LOUISIANA- LA</td></tr>
	<tr><td>row = 23</td><td>row = MAINE- ME</td></tr>
	<tr><td>row = 24</td><td>row = MARSHALL ISLANDS- MH</td></tr>
	<tr><td>row = 25</td><td>row = MARYLAND- MD</td></tr>
	<tr><td>row = 26</td><td>row = MASSACHUSETTS- MA</td></tr>
	<tr><td>row = 27</td><td>row = MICHIGAN- MI</td></tr>
	<tr><td>row = 28</td><td>row = MILITARY AFRICA- AE</td></tr>
	<tr><td>row = 29</td><td>row = MILITARY AMERICAS- AA</td></tr>
	<tr><td>row = 30</td><td>row = MILITARY CALIFORNIA- AP</td></tr>
	<tr><td>row = 31</td><td>row = MILITARY CANADA- AE</td></tr>
	<tr><td>row = 32</td><td>row = MILITARY EUROPE- AE</td></tr>
	<tr><td>row = 33</td><td>row = MILITARY FLORIDA- AA</td></tr>
	<tr><td>row = 34</td><td>row = MILITARY MIDDLE EAST- AE</td></tr>
	<tr><td>row = 35</td><td>row = MILITARY NEW YORK- AE</td></tr>
	<tr><td>row = 36</td><td>row = MILITARY PACIFIC- AP</td></tr>
	<tr><td>row = 37</td><td>row = MINNESOTA- MN</td></tr>
	<tr><td>row = 38</td><td>row = MISSISSIPPI- MS</td></tr>
	<tr><td>row = 39</td><td>row = MISSOURI- MO</td></tr>
	<tr><td>row = 40</td><td>row = MONTANA- MT</td></tr>
	<tr><td>row = 41</td><td>row = NEBRASKA- NE</td></tr>
	<tr><td>row = 42</td><td>row = NEVADA- NV</td></tr>
	<tr><td>row = 43</td><td>row = NEW HAMPSHIRE- NH</td></tr>
	<tr><td>row = 44</td><td>row = NEW JERSEY- NJ</td></tr>
	<tr><td>row = 45</td><td>row = NEW MEXICO- NM</td></tr>
	<tr><td>row = 46</td><td>row = NEW YORK- NY</td></tr>
	<tr><td>row = 47</td><td>row = NORTH CAROLINA- NC</td></tr>
	<tr><td>row = 48</td><td>row = NORTH DAKOTA- ND</td></tr>
	<tr><td>row = 49</td><td>row = NORTHERN MARIANA ISLANDS- MP</td></tr>
	<tr><td>row = 50</td><td>row = OHIO- OH</td></tr>
	<tr><td>row = 51</td><td>row = OKLAHOMA- OK</td></tr>
	<tr><td>row = 52</td><td>row = OREGON- OR</td></tr>
	<tr><td>row = 53</td><td>row = PALAU- PW</td></tr>
	<tr><td>row = 54</td><td>row = PENNSYLVANIA- PA</td></tr>
	<tr><td>row = 55</td><td>row = PUERTO RICO- PR</td></tr>
	<tr><td>row = 56</td><td>row = RHODE ISLAND- RI</td></tr>
	<tr><td>row = 57</td><td>row = SOUTH CAROLINA- SC</td></tr>
	<tr><td>row = 58</td><td>row = SOUTH DAKOTA- SD</td></tr>
	<tr><td>row = 59</td><td>row = TENNESSEE- TN</td></tr>
	<tr><td>row = 60</td><td>row = TEXAS- TX</td></tr>
	<tr><td>row = 61</td><td>row = TRUST TERRITORIES- TT</td></tr>
	<tr><td>row = 62</td><td>row = UTAH- UT</td></tr>
	<tr><td>row = 63</td><td>row = VERMONT- VT</td></tr>
	<tr><td>row = 64</td><td>row = VIRGIN ISLANDS- VI</td></tr>
	<tr><td>row = 65</td><td>row = VIRGINIA- VA</td></tr>
	<tr><td>row = 66</td><td>row = WASHINGTON- WA</td></tr>
	<tr><td>row = 67</td><td>row = WEST VIRGINIA- WV</td></tr>
	<tr><td>row = 68</td><td>row = WISCONSIN- WI</td></tr>
	<tr><td>row = 69</td><td>row = WYOMING- WY</td></tr>
</table>


Is This A Good Question/Topic? 0
  • +

Replies To: ASP Classic XML to Table in html page

#2 jayeomer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-July 10

Re: ASP Classic XML to Table in html page

Posted 24 September 2013 - 08:26 PM

CLEAN XML DATA (SHORT VIEW)
<data>
  <variable name="id">
    <row>
      <column>1</column>
    </row>
    <row>
      <column>2</column>
    </row>
    <row>
      <column>3</column>
    </row>
    <row>
      <column>4</column>
    </row>
    <row>
      <column>5</column>
    </row>
  </variable>
  <variable name="states">
    <row>
      <column>ALABAMA- AL</column>
    </row>
    <row>
      <column>ALASKA- AK</column>
    </row>
    <row>
      <column>AMERICAN SAMOA- AS</column>
    </row>
    <row>
      <column>ARIZONA- AZ</column>
    </row>
    <row>
      <column>ARKANSAS- AR</column>
    </row>
  </variable>
</data>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1