我如何将HTML转换为字符串。格式
问题描述:
我在HTML中有基本代码,我想将此代码转换为字符串格式。我如何将HTML转换为字符串。格式
<table id="rounded-corner" summary="2007 Major IT Companies' Profit" style="text-align: center">
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Název</th>
<th scope="col" class="rounded">Web</th>
<th scope="col" class="rounded">Popis</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-q4">Delete</th>
</tr>
</thead>
<tbody>
,我想这HTML使用到的String.format。
StringBuilder data = new StringBuilder();
data.Append(string.Format(@"<table id="rounded-corner" summary="2007 Major IT Companies' Profit" style="text-align: center">
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Název</th>
<th scope="col" class="rounded">Web</th>
<th scope="col" class="rounded">Popis</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-q4">Delete</th>
</tr>
</thead>
<tbody>"));
我有问题,这个符号“”对的String.Format,你能帮助我,我怎么能做到这一点。
你需要把\"
这样的:
string.Format(@"<table id=\"rounded-corner\" summary=\"2007 Major IT Companies' Profit\" style=\"text-align: center\">
<thead>
<tr>
<th scope=\"col\" class=\"rounded-company\"></th>
<th scope=\"col\" class=\"rounded\">Název</th>
<th scope=\"col\" class=\"rounded\">Web</th>
<th scope=\"col\" class=\"rounded\">Popis</th>
<th scope=\"col\" class=\"rounded\">Edit</th>
<th scope=\"col\" class=\"rounded-q4\">Delete</th>
</tr>
</thead>
<tbody>")
,或者您可以'
这样的:
string.Format(@"<table id='rounded-corner' summary='2007 Major IT Companies Profit' style='text-align: center'>
<thead>
<tr>
<th scope='col' class='rounded-company'></th>
<th scope='col' class='rounded'>Název</th>
<th scope='col' class='rounded'>Web</th>
<th scope='col' class='rounded'>Popis</th>
<th scope='col' class='rounded'>Edit</th>
<th scope='col' class='rounded-q4'>Delete</th>
</tr>
</thead>
<tbody>")
+0
thx结果来自你和krisdy是工作thx,但我会用你的结果,因为它更清晰 – 2014-09-24 07:04:21
每"
的HTML里面使其""
:
<table id=""rounded-corner"" summary=""2007 Major IT Companies' Profit"" style=""text-align: center"">
<thead>
<tr>
<th scope=""col"" class=""rounded-company""></th>
<th scope=""col"" class=""rounded"">Název</th>
<th scope=""col"" class=""rounded"">Web</th>
<th scope=""col"" class=""rounded"">Popis</th>
<th scope=""col"" class=""rounded"">Edit</th>
<th scope=""col"" class=""rounded-q4"">Delete</th>
</tr>
</thead>
<tbody>
答
你需要把\"
这样的:
string.Format(@"<table id=\"rounded-corner\" summary=\"2007 Major IT Companies' Profit\" style=\"text-align: center\">
<thead>
<tr>
<th scope=\"col\" class=\"rounded-company\"></th>
<th scope=\"col\" class=\"rounded\">Název</th>
<th scope=\"col\" class=\"rounded\">Web</th>
<th scope=\"col\" class=\"rounded\">Popis</th>
<th scope=\"col\" class=\"rounded\">Edit</th>
<th scope=\"col\" class=\"rounded-q4\">Delete</th>
</tr>
</thead>
<tbody>")
,或者您可以'
这样的:
string.Format(@"<table id='rounded-corner' summary='2007 Major IT Companies Profit' style='text-align: center'>
<thead>
<tr>
<th scope='col' class='rounded-company'></th>
<th scope='col' class='rounded'>Název</th>
<th scope='col' class='rounded'>Web</th>
<th scope='col' class='rounded'>Popis</th>
<th scope='col' class='rounded'>Edit</th>
<th scope='col' class='rounded-q4'>Delete</th>
</tr>
</thead>
<tbody>")
+0
thx结果来自你和krisdy是工作thx,但我会用你的结果,因为它更清晰 – 2014-09-24 07:04:21
答
每"
的HTML里面使其""
:
<table id=""rounded-corner"" summary=""2007 Major IT Companies' Profit"" style=""text-align: center"">
<thead>
<tr>
<th scope=""col"" class=""rounded-company""></th>
<th scope=""col"" class=""rounded"">Název</th>
<th scope=""col"" class=""rounded"">Web</th>
<th scope=""col"" class=""rounded"">Popis</th>
<th scope=""col"" class=""rounded"">Edit</th>
<th scope=""col"" class=""rounded-q4"">Delete</th>
</tr>
</thead>
<tbody>
只需使用反斜杠即可忽略双引号。某些行'
我同意@NayanaAdassuriya .. \指定它不是字符串的结尾。 – 2014-09-24 07:01:26
回答
你需要把
\"
这样的:,或者您可以
'
这样的:thx结果来自你和krisdy是工作thx,但我会用你的结果,因为它更清晰 – 2014-09-24 07:04:21
每
"
的HTML里面使其""
:相关问题