如何访问 XSDocument 元素?
How to access XSDocument element?
我有以下 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>
我不知道如何访问此模式中的特定元素以及命名空间如何适合in.I已尝试将命名空间添加到所有名称,但无济于事。
有什么想法吗?
此页面上的第一个 link 是 'How to find an element with a specific attribute (C#)',这似乎正是您的问题。
我有以下 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>
我不知道如何访问此模式中的特定元素以及命名空间如何适合in.I已尝试将命名空间添加到所有名称,但无济于事。
有什么想法吗?
此页面上的第一个 link 是 'How to find an element with a specific attribute (C#)',这似乎正是您的问题。