我有以下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>我不知道如何访问这个模式中的特定元素,以及命名空间是如何适应的,我尝试在所有名称中添加名称空间,但都没有效果。
有什么想法吗?
发布于 2019-11-22 16:33:58
该页面的第一个链接是“如何找到具有特定属性(C#)的元素”,这似乎正是您的问题所在。
https://stackoverflow.com/questions/58935210
复制相似问题