2012-01-02 1 views
0
<?xml version="1.0" encoding="UTF-8"?> 
<definitions xmlns:def="http://www.w3.org/2002/ws/databinding/examples/6/09/" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<types> 
     <xs:schema xmlns="http://www.w3.org/2002/ws/databinding/examples/6/09/" 
       targetNamespace="http://www.w3.org/2002/ws/databinding/examples/6/09/" 
       elementFormDefault="qualified"> 
     <xs:include xmlns:wsdl11="http://schemas.xmlsoap.org/wsdl/" 
        xmlns:soap11enc="http://schemas.xmlsoap.org/soap/encoding/" 
        schemaLocation="http://www.w3.org/2002/ws/databinding/examples/6/09/static/Included.xsd"/> 
     <xs:include xmlns:wsdl11="http://schemas.xmlsoap.org/wsdl/" 
        xmlns:soap11enc="http://schemas.xmlsoap.org/soap/encoding/" 
        schemaLocation="http://www.w3.org/2002/ws/databinding/examples/6/09/static/Included.xsd"/> 
     <xs:element name="echoInclude"> 
      <xs:complexType> 
       <xs:sequence> 
        <xs:element ref="ex:include"/> 
       </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:schema> 
    </types> 
</definitions> 

からコンテンツを取得/解析する:schema要素LINQのクエリは、私はすべてのXSの<strong>のschemaLocation</strong>属性の値を取得したい。このXML(WSDL)上記のXMLでは

答えて

0
:内部XSである要素を含みます

まず、XML文書をロードし、名前空間を設定して要素名を照会します。

XDocument doc = XDocument.Load(file); 
XNamespace ns= "http://www.w3.org/2001/XMLSchema"; 

var nodeList = from ele in doc.Descendants(ns + "schema").Descendants(ns + "include") 
        select ele.Attribute("schemaLocation").Value; 

foreach (var t in nodeList) 
    { 
    Console.WriteLine(t); 
    } 
+0

Uは、xsので、それはdoc.Descendants.Descendentsのようなものであるべきだと思います:スキーマが内部文書である内部のタイプ、したがって、それは、参照として私のポストを考えてみましょう – Abhi

+0

動作していないです。あなたは試してみることができます - doc.Descendants(ns + "schema")。子孫(ns + "include") – adatapost

+0

ありがとう、 – Abhi

関連する問題