Answer the question
In order to leave comments, you need to log in
How to get list of XML nodes via XPath which has XmlNamespace?
I'm trying to find `complexType` elements in an XSD document via `XPath`.
But I clearly don’t understand how namespaces work and how to set up `XmlNamespaceManager`
_document = New XmlDocument()
_document.Load(current_xsd)
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(_document.NameTable)
nsmgr.AddNamespace("xs", "http://common")
Dim nodeList As XmlNodeList = _document.SelectNodes("//complexType", nsmgr)
For Each node As XmlNode In nodeList
Next
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Catalog" targetNamespace="http://catalog" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xc="http://common" xmlns="http://catalog">
<xs:import namespace="http://common" schemaLocation="Common.xsd"/>
<xs:complexType name="brigade">
<xs:complexContent>
<xs:extension base="xc:extraFieldContainer">
<xs:sequence>
<xs:element name="brigadier" type="staffPersonnelNumber" minOccurs="1" maxOccurs="1"/>
<xs:element name="employees" type="employeCollection" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question