Reputation: 3881
I need to make my xml a valid string so we can feed it into the parser. For some reason, I'm having trouble getting a valid string. All the examples we have are more of an abbreviated version, but this one needs to be the full version (i.e. Canvas.Clip). My question is, how do I make the following valid code?
static const char* pCanvasData = "\
<Canvas>\
<Canvas.Name = \"Test\" />\
<Canvas.RenderTransform = \"1, 0, 0, 1, 0, 290\" />\
<Canvas.Opacity> = \"0.5\" />\
<Canvas.Clip = \"M 40,75 H 30 V 25 Z\" />\
<Path Fill=\"#FFFF0000\" />\
<Path.Data>\
<PathGeometry>\
<PathFigure StartPoint=\"30,70\" IsClosed=\"true\" />\
<PolyLineSegment Points=\"110,170\" />\
<PolyLineSegment Points=\"80,170\" />\ **********this is where the compiler says "error missing closing quote" and last PolyLineSegment is the wrong color (black instead of red), but it turns red again at the last quote of "80,170\" />\
</PathFigure>\
</PathGeometry>\
<\Path.Data>\
</Canvas>";
There's probably a missing quote but I don't see it. Also, there may be something I'm missing with slashes, since this is the first time doing non-abbreviated xml for this type of xps. I'd appreciate any help! Just to head off any questions, we can't feed the xml into xml classes. I need the char* here.
Upvotes: 0
Views: 2991
Reputation: 4527
In C++11 there are raw string literals, which might help:
static const char* pCanvasData = R"zzz(
<Canvas>
<Canvas.Name = "Test" />
<Canvas.RenderTransform = "1, 0, 0, 1, 0, 290" />
...
)zzz";
This way you don't have to escape any quotes.
Upvotes: 2
Reputation: 121
It seems you may have an unwanted extra whitespace character after "\". Just place the mouse cursor after this line and hit erase button one step.
You can actually see this in Notepad++, if you choose View -> Show Symbol -> Show Whitespace and TAB
Upvotes: 2