0

Is it bad practice to store a properly formatted HTML fragment in an XML column in SQL Server?

For example:

<p>A phase of the moon is shown below.</p><p><img src="../../../graphics/saved/100022.jpg" alt="" /></p><p>Which pair of diagrams shows the moons phase immediately before and immediately after this phase?</p>
kyletme
  • 441
  • 4
  • 17
  • Apart from being sure that any HTML you enter there is actually syntactically valid XML, there are a couple things you'd need to be wary of, such as HTML entities and generally invalid XML characters. But why would you want to store it as XML? Storing it as XML would give some advantage if you were planning to parse it (e.g. search for p nodes with a child img node), but other than that, I'm not sure why you'd bother. – ZLK Sep 05 '18 at 01:24
  • It will bite you sooner or later. Take a peek at https://stackoverflow.com/questions/5558502/is-html5-valid-xml – John Cappelletti Sep 05 '18 at 01:32

0 Answers0