Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert html table to xml

Status
Not open for further replies.

delfy

MIS
Feb 8, 2005
96
JM
How would i using delphi covert a html table to xml?
 
What is the structure of your target xml file?

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
i prefer element style xml example

<root>
<client>
<last_name>Brown</last_name>
<first_name>Dan</first_name>
<phone_1>888-9690-9</phone_1>
</client>
<client>
<last_name>Adlam</last_name>
<first_name>David</first_name>
<phone_1>999-3064</phone_1>
</client>
<Root>


here is a piece of the html

<table border="0" cellspacing="0" cellpadding="4">
<tr><td colspan="12"><B>PREFERENCE SHARES</B></td></tr>

<tr bgcolor="#ECECEC">
<td class="GreyBorder">
<p class="Text">&nbsp;
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=max365&Direction=ASC&TradingDate=08/16/2005">52<br>
Week <br>High</a></strong></p>

</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=min365&Direction=ASC&TradingDate=08/16/2005">52
<br>
Week<br> Low</a></strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=security&Direction=ASC&TradingDate=08/16/2005">Security</a></strong></p>

</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong>Prev Yr<br>Div($)</strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><!---<a href="controller.php?action=view_quote&Column=DivShare2003&Direction=ASC&TradingDate=08/16/2005">--->Current Yr<br>Div ($)<!---</a>---></strong></p>
</td>
<!--
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="Text"><strong><a href="controller.php?action=view_quote&Column=DivShare2002&Direction=DESC">Previous Div
per <br>
share</a></strong></p>
</td>-->

<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=volume&Direction=ASC&TradingDate=08/16/2005">Volume
<br>
(non block) ($)</a></strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=hightoday&Direction=ASC&TradingDate=08/16/2005">Today's
<br>
High ($)</a></strong></p>
</td>

<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=lowtoday&Direction=ASC&TradingDate=08/16/2005">Today's<br>
Low ($)</a></strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=price&Direction=ASC&TradingDate=08/16/2005">Last
<br>
Sale ($)</a></strong></p>
</td>

<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=pricechange&Direction=ASC&TradingDate=08/16/2005">Change ($)</a></strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=closebid&Direction=ASC">Closing
<br>
Bid ($)</a></strong></p>
</td>
<td class="GreyBorder" nowrap valign="top">
<p align="center" class="smalltext"><strong><a href="controller.php?action=view_quote&Column=closeask&Direction=ASC&TradingDate=08/16/2005">Closing<br>Ask ($)</a></strong></p>

</td>
</tr>
<tr>
<td class="GreyBorder">
<p class="Text"><img src="images/mov_none.gif">
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.41</p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.35</p>

</td>
<td class="GreyBorder" nowrap>
<p class="Text">JPS5D </p>
</td>
<td class="GreyBorder" nowrap>
<p align="center" class="smalltext"><strong>0.13</strong></p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"><strong>0.05</strong></p>

</td>
<!--
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> NA</p>
</td>-->
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0</p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.00</p>
</td>

<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.00</p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.36</p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.00</p>

</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.35</p>
</td>
<td class="GreyBorder" nowrap>
<p align="right" class="smalltext"> 0.00</p>
</td>
</tr>
</table>
 
So are you wanting to convert the HTML posted above into some XML like this:
Code:
<preference_shares>
  <preference_share>
    <_52_week_high>0.41</_52_week_high>
    <_52_week_low>0.35</_52_week_low>
    <security>JPS5D</security>
    ...
  </preference_share>
</preference_shares>

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
I'm not sure how much you know about XML, but if you are starting to learn it then go to and have a look at the XML Tutorials available in the navigation bar (left-hand side).

The following link shows how to download the html code of a webpage and strip data out of it - but it is quite a long-winded method and if the html structure of your source page changes then so does your code:

I know that XSLT can be used to convert XML to HTML but I'm not sure whether it can be used in the opposite direction i.e. for HTML to XML transformations. Might be worth looking into though.

It might even be worth posting a question in the XML forum (forum426) to find out if there are any standard ways of doing this.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top