c# - XmlNodeList (why is this empty) -


I do not understand why this nodelist is empty

  XmlDocument document = New XmlDocument (); Document.Load (xmlpath); XmlNodeList nodes = document. Selection Nodes ("/ ProtectiveRespense / Root ITEM / Features / Attributes");  

here XmlFile

   & Lt; RootItem xsi: type = "section" xmlns = "http://systinet.com/wsdl/com/osm/webservices/service/" & gt; & Lt; Let's blame & gt; & Lt; Attribute & gt; & Lt; DataDictionary xsi: nil = "true" /> & Lt; Datatype & gt; String & lt; / Datatype & gt; & Lt; DISPLAYNAME & gt; IDENT_NR & lt; / DISPLAYNAME & gt; & Lt; Key & gt; True & lt; / Key & gt; & Lt; Name & gt; IDENT_NR & lt; / Name & gt; & Lt; Search & gt; True & lt; / Search & gt; & Lt; UserAttribute & gt; True & lt; / UserAttribute & gt; & Lt; Price & gt; 9662744 & lt; / Pricing & gt; & Lt; / Properties & gt; & Lt; Attribute & gt; & Lt; DataDictionary xsi: nil = "true" /> & Lt; Datatype & gt; String & lt; / Datatype & gt; & Lt; DISPLAYNAME & gt; A & lt; / DISPLAYNAME & gt; & Lt; Key & gt; True & lt; / Key & gt; & Lt; Name & gt; A & lt; / Name & gt; & Lt; Search & gt; True & lt; / Search & gt; & Lt; UserAttribute & gt; True & lt; / UserAttribute & gt; & Lt; Price & gt; 00 & lt; / Pricing & gt; & Lt; / Properties & gt; & Lt; / RootItem & gt; & Lt; / StructureResponse & gt;  

In the last script, I want to get an array string which contains every attribute in it.

Thanks Stephen

The answer to the user marc_s is actually correct on the XML namespace Notice that their code sample, however, will not work directly for your example. Here's a complete sample that works with the XML you gave (though I had to clean it ... there was a closed tag missing for attributes ).

  string xmlData = @ "& lt ;? Xml version = '1.0' encoding = 'UTF-8'? & Gt; & lt; citation protected xmlns: xsi = 'http: // www .w3.org / 2001 / XMLSchema-instance 'xmlns: Xsd =' http: //www.w3.org/2001/XMLSchema 'xmlns =' http: // nts-de-osm1-pxc / webservices / '& gt; ; & Lt; Consolidated items xsi: nil = 'true' xmlns = 'http://systinet.com/wsdl/com/osm/webservices/service/' / & gt; & lt; rootItem xsi: type = 'part' Xmlns = 'http: //systinet.com/wsdl/com/osm/webservices/service/' & gt; & lt; attributes & gt; & lt; specialty & gt; & lt; dataDictionary xsi: nil = 'true' / & Gt; & lt; datatype & gt; String & lt; / dataType & gt; & lt; displayName & gt; IDCNN & lt; / displayName & gt; & gt; & gt; true & lt; / key & Gt; & lt; Name & gt; IDENT_NR & lt; / Name & gt; & lt; Search & gt; True & lt; / search & gt; & lt; userAttribute & gt; Tr ue & lt; / UserAttribute & gt; & lt; value & Gt; 9662744 & lt; / pricing & gt; & lt; / Properties & gt; & lt; attribute & gt; & lt; dataDictionary xsi: nil = 'true' / & gt; & Lt; Datatype & gt; String & lt; / Datatype & gt; & Lt; DISPLAYNAME & gt; A & lt; / DISPLAYNAME & gt; & Lt; Key & gt; True & lt; / Key & gt; & Lt; Name & gt; A & lt; / Name & gt; & Lt; Search & gt; True & lt; / Search & gt; & Lt; UserAttribute & gt; True & lt; / UserAttribute & gt; & Lt; Price & gt; 00 & lt; / Pricing & gt; & Lt; / Properties & gt; & Lt; / Attributes & gt; & Lt; / RootItem & gt; & Lt; / StructureResponse & gt; "XmlDocument Document = New XmlDocument (); XmlNamespaceManager namespaceManager = New XmlNamespaceManager (document.NameTable); Namespace Manager.AdnatesSpace (" a "," http: // nts-de-osm1-pxc / webservices / "); Namespace Manager Aid namespace ("b", "http://systinet.com/wsdl/com/osm/webservices/service/"); document.load xml (xmlData); XmlNodeList nodes = document.selected node ("/ a:  

I suggest that there should be something more to study XML: structure: Response / B: root item / b: attributes / b: attribute ", namespace manager); // 'not In S 'now includes two items Try I skimming.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -