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.


VulpesRank #55 · 29.2K reputationPosted Jan 31, 2013, 4:32 AM EST
Rishikesh Kumar SinghRank #1,250 · 1.4K reputationPosted Jan 31, 2013, 1:03 AM EST
1).Set an id to your div.
2).Set attribute runat="server".
3).Then you can get the style properties from the code behind.
For example:-
in code behind write down
string aa = First_div.Style.Value;
In this way you can do..
If it helps you then mark it as an accepted answer otherwise let me know..!!
visweswaran varadarajan10 reputationPosted Jan 31, 2013, 2:20 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 31, 2013, 3:58 AM EST
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