0

Example, I have a string of html

<div id = "this is a new "id" and the new " attribute", ">

How do I get the content of id ; include quote, result like

this is a new "id" and the new " attribute", ;

I'm from Vietnam and the ability to express in English is very poor, thank you so much to read my question and if you can, please give me a a resolution

Kiên Trần Trung
  • 347
  • 1
  • 5
  • 16
  • 6
    That's invalid HTML for one. You should use single quotes to define the attribute if you require double quotes inside. – Rob Nov 21 '17 at 07:46
  • I have accepted the edit suggestion you requested, thank you – Kiên Trần Trung Nov 21 '17 at 07:54
  • 1
    You can also use `
    ` to encode double quotes inside attributes. This way you'll also conform to the Xml spec.
    – C.Evenhuis Nov 21 '17 at 08:04
  • _"C# will automatic delete quote in two quote of id="""_ -- no, not really. C# doesn't remove characters from existing strings. Perhaps you mean that you are using some class that actually _interprets_ the HTML, and which has to deal with quotes. If so, you need to be clear about that. Your question needs a good [mcve] that shows _exactly_ how you are currently handling the HTML, what exactly you've tried so far to do what you want, and explains _precisely_ how what the code does now is different from what you want. – Peter Duniho Nov 21 '17 at 08:15
  • The problem here is that I will not be deciding on the format or data used to format the id, for example, the input string containing the ", how can html, xml or something understand it is still attribute of that id, ex: the input string is head "i" ng, id will have the form id = "head" i "ng" I think this is the main reason that c # can not be read, does anyone have any solution to avoid it or solve this problem? – Kiên Trần Trung Nov 21 '17 at 08:16
  • Where does this HTML come from? What exactly does the string look like in your variable, exactly as shown here? – CodeCaster Nov 21 '17 at 08:20
  • @CodeCaster , i did't know your question, explain me if you want, thank you, howerver. – Kiên Trần Trung Nov 21 '17 at 08:27

1 Answers1

0

Use like this,

<div id = 'this is a new "id" and the new " attribute", '>

If you want single quotes inside, use like

<div id = "this is a new 'id' and the new ' attribute', ">
Naveen Kumar V
  • 2,559
  • 2
  • 29
  • 43