Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

I dont know how to explain what I want but I will try :)

I want to my program to read this XML

XML
<tr> 
<td>Oslo</td>
<td>02:29</td><td>03:59</td><td>13:26</td><td>18:03</td><td>22:43</td><td>00:13</td>
</tr>

<tr> 
<td>Nordkapp</td>
<td>02:44</td><td>04:14</td><td>13:47</td><td>18:27</td><td>23:10</td><td>00:40</td>

</tr>



Well..My program should get the time and write it in textbox
the first line will be for Oslo and the second for Nordkapp(example: Oslo: 2:29, 3:59, 13:26, etc...)

I hope you understand what I want XD
And sorry for my bad English ;)
Posted

Add some root tag to this code, and you will get a well-formed XML. Let's say, you surround it with <table>… </table>. As soon as you do it, you can do whatever you want with any of the XML parsers bundled with .NET.

Here is my short overview of those parsers:


  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


Good luck,
—SA
 
Share this answer
 
v2
Comments
Pandvi 2-Jul-12 2:09am    
Nice ! My 5.
Sergey Alexandrovich Kryukov 2-Jul-12 2:35am    
Thank you, Pandvi.
--SA
That's not XML. It's a fragment of HTML. The XML parser will not work with what you've posted as it is malformed for XML.
 
Share this answer
 
Comments
MoDy kareem 1-Jul-12 19:55pm    
aha..ok thanks for the information :)
Sergey Alexandrovich Kryukov 2-Jul-12 0:04am    
...that's correct, but you can slightly modify this HTML fragment (which is, out of valid context, is also not a valid HTML, as the element "table" is missing) to make it a well-formed XML. And then -- please see my answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900