3
Vote

How to obtain the Value of an element of complexType where mixed="true"

description

I am using LINQ-to-XSD to process XML elements named "labl", defined in the schema as follows:
 
<xs:complexType name="lablType" mixed="true">
    ...[definitions of optional elements and attributes]...
</xs:complexType>
 
My actual XML file looks like this:
 
<labl>
    The text of the label
</labl>
 
where <labl /> is defined in the schema as being of type "lablType". My current C# code using LINQ-to-XSD looks like this:
 
var lablNodes = from children in rootNode.Load("fileName").childNode
                from labls in children.labl
                select labls;
 
foreach (lablType labl in lablNodes)
{
    string label = ((XElement)labl).Value.Trim();
}
 
In other words, I am having to revert to untyped LINQ-to-XML to get the actual text of the <labl /> node, because the automatically generated class "lablType" does not seem to include a property for the text, only the attributes.
 
Is there a way to do this using typed variables/LINQ-to-XSD? Am I missing something simple?
 
Thanks in advance,
 
Ed Graham

comments

robbie_hinch wrote Oct 13, 2011 at 2:09 PM

I have just bumped into the same problem and can't find much info about how to get round it

wrote Aug 29, 2012 at 1:23 PM

unfug_rockz wrote Aug 29, 2012 at 1:27 PM

Same Problem here.
mixed="true" not working

Is there an working alternative to linqtoxsd?

wrote Feb 21, 2013 at 10:49 PM