Click here to Skip to main content
16,010,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can do this in WPF
C#
string xaml = "<grid margin="0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><textblock text="Page one" fontsize="32" foreground="White" horizontalalignment="Center" verticalalignment="Center" /> </grid>";
C#
StringReader stringReader = new StringReader(xaml);
            XmlReader xmlReader = XmlReader.Create(stringReader);
            UIElement MyVisualTree = (UIElement)XamlReader.Load(xmlReader);
            Layout.Children.Add(MyVisualTree);

I want to define the structure of the "string xaml = ..." in an XML file as follows:
C#
<menuitem tipo="C" xaml=" <Grid> ... </Grid>" estado="E" /> 


but trying to process tells me that there is an error in

"<" Grid
Is there any way to tell xml try everything in ContenidoGrid = ".." , treat it as a simple text and not be posting in special characters (< , >).
Posted
Updated 10-Sep-13 4:24am
v2

1 solution

The last line of your code sample is not XML at all. It is not well-formed and cannot be parsed.

Before working with XAML and other XML applications, you need to learn XML itself. Your problem with the syntax is very basic: you cannot add any tags in the opening tags. You only insert inner XML between opening and closing tags:
HTML
<someElement someAttribute="you cannot have XML inside the tag">
   <!-- any inner XML, should also be well-formed -->
</someElement>
Please see:
http://en.wikipedia.org/wiki/XML[^],
http://www.w3.org/TR/xml/[^],
http://www.xml.com/axml/testaxml.htm[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900