I want to use the class XmlSchema to parse a schema but I can't find how to get a reference to the Image and Size elements in the schema below. I'm working on an app that will have a form based on a schema.
I have the schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:complexType>
<xs:sequence>
<xs:element name="Image" type="FileUpload" />
<xs:element name="Size" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="FileUpload">
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:schema>
How can I do this?
What about this..?
foreach(var size in doc.Root.DescendantNodes().OfType<XElement>()
.Select(x => x.Size).Distinct())
{
Console.WriteLine(size);
}
or
foreach(var image in doc.Root.DescendantNodes().OfType<XElement>()
.Select(x => x.Image).Distinct())
{
Console.WriteLine(image);
}
you could also use XPATH
XmlDocument xdoc = new XmlDocument();
xdoc.Load(path to your xml schema file);
XmlNodeList list = xdoc.SelectNodes("//Image");
XmlNodeList list2 = xdoc.SelectNodes("//Size");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.