English 中文(简体)
将Html带进C#的护栏
原标题:Storing Html into a string in C#
  • 时间:2012-01-16 07:07:22
  •  标签:
  • c#
  • string

In my project, I need to read some URLs and store the starting tags into some variables, but the project won t compile. May be, its because I am not using the assignment to the string correctly. Following is what i tried and got the compile error

string startTag = "<span id="productLayoutForm:OurPrice" class="pdp_details_hs18Price" itemprop="price">";

string anotherStartTag = "<span class="price final-price our fksk-our" id="fk-mprod-our-id">Rs.<span class="small-font">"

请指出,上述正确守则是什么,我可以学习如何将这种超文本储存起来加以扼杀,或如何为这种假象使用座标。

最佳回答

You need to "escape" the quotes in your strings, for example:

string startTag = "<span id="productLayoutForm:OurPrice" class="pdp_details_hs18Price" itemprop="price">";

The before the quotes which are within the string notess the C# codificationer that the quotes are part of the string and not thestart/end of the string.

问题回答

“信号表示体的开始和结束。 因此,在你必须逃离的中间,通过在前方打下斜坡,这样做。 同此:“





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签