English 中文(简体)
参考使用XmlSchema的xml schema的要素
原标题:Get a reference to the elements of a xml schema using XmlSchema
  • 时间:2012-01-13 16:49:56
  •  标签:
  • c#
  • .net
  • xsd

我想利用XmlSchema这一类推土机,但我可以找到如何在下面的图表中提及图像和要素。 我工作时,用的是一张基于chem的表格。

我有计划:

<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>

我如何能够这样做?

问题回答

这一点是什么?

foreach(var size in doc.Root.DescendantNodes().OfType<XElement>()
        .Select(x => x.Size).Distinct())
{
    Console.WriteLine(size);
}

foreach(var image in doc.Root.DescendantNodes().OfType<XElement>()
        .Select(x => x.Image).Distinct())
{
    Console.WriteLine(image);
}

也可以使用XPATH

XmlDocument xdoc = new XmlDocument(); 
xdoc.Load(path to your xml schema file);
XmlNodeList list = xdoc.SelectNodes("//Image");
XmlNodeList list2 = xdoc.SelectNodes("//Size");




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签