我具有以下XSD文件,但无法获得名称为“ document”的内部元素:
到目前为止,我已经尝试了以下步骤但无济于事:
XDocument doc=Xdocument.Load([path]);
XNamespace ns="https://fr7.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml";
-------------------------------------我尝试了所有这些:----- ---------------------------
var children=doc.Elements().Elements(); //here i get the immediate children, but cant filter
var documentNode=children.Where(x=>x.Attribute("name").Value=="document").First();
var documentNode=children.Element("document");
var documentNode=children.Element(ns+"document");
XML文件
<!--This XML file does not appear to have any style information associated with it. The document tree is shown below.-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml" targetNamespace="http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml" elementFormDefault="qualified">
<link type="text/css" id="dark-mode" rel="stylesheet" href=""/>
<style type="text/css" id="dark-mode-custom-style"/>
<xs:annotation></xs:annotation>
<xs:element name="document"><xs:element> ----how do i get this one
<xs:complexType name="something"></xs:complexType>
</xs:schmea>
我不知道如何访问此模式中的特定元素以及名称空间如何适合。我尝试将所有名称空间添加到名称中都无济于事。
有什么想法吗?
此页面上的第一个链接是“如何查找具有特定属性(C#)的元素”,这似乎正是您的问题。