简体   繁体   中英

Xpath in XSD C#

I have an XSD file such as:

<xs:schema targetNamespace="...">
 <xs: import namespace="...">
<xs: import namespace="...">
<xs: import namespace="...">
<xs:element name="FSM">
<xs:annotation>
<xs:appinfo>
<Info>
<ID> 44</ID>
<Priority>3</Priority>
</Info>
</xs:appinfo>
</xs:annotation>
</xs:element>
</schema>

I hvae more them one "xs:element" in the schema,but it's just an example... I can't get the FSM node. I tried

`xDoc.SelectSingleNode(@"//FSM");` 

(xDoc is XMLDocument) but I got null. I tried the xpath @"//*[name()=FSM" and i got null. What the xPath to get the FSM element. I want something generic so i could find it wherever it is in all the elements in the XSD. PS I can only use.Net 2...

If you want to apply XPath to the schema itself then you need a path like //xs:element[@name = 'FSM'] .

I think you'll have to add the xs namespace to the xpath statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM