Hi,
I have a string "
I want to extract widht, height, rowheader & columnsize value from above string through C#.net
I tried to load the above string in XMLdocument, but I used to receive an exception.
Please suggest me to proceed this.
Thanks in Advance.

VulpesPosted Jan 31, 2013, 9:32 AM
VulpesPosted Feb 1, 2013, 6:42 AM
This should work:
visweswaran varadarajanPosted Jan 31, 2013, 9:58 PM
I tried in framework 2.0. xml.linq is not available. How can I achieve the same in FW 2.0.
VulpesPosted Jan 31, 2013, 8:58 AM
I've assumed that there should in fact be quotes around 200, 700 and 4 because it's good practice to always enclose them in quotes, even though the HTML spec allows them to be omitted in certain circumstances. If there are no quotes, then an 'ad hoc' method will be needed to parse out the required values:
using System;
using System.Xml.Linq;
class Program
{
static void Main()
{
string html = "\"4\">
XElement div = XElement.Parse(html);
int width = (int)div.Attribute("width");
int height = (int)div.Attribute("height");
bool rowheader = (bool)div.Attribute("rowheader");
int columnsize = (int)div.Attribute("columnsize");
Console.WriteLine("Width = {0}", width);
Console.WriteLine("Height = {0}", height);
Console.WriteLine("Row Header = {0}", rowheader);
Console.WriteLine("Column Size = {0}", columnsize);
Console.ReadKey();
}
}
The output should be:
Width = 200
Height = 700
Row Header = True
Column Size = 4