Hi,
How can i get all the nodes with attribute Name = "Publisher" or
Name="Administr ator" using XPath query and C# for this xml doc?
<GetRoleCollect ionFromUser
xmlns=\"http://schemas.microso ft.com/sharepoint/soap/directory/\">
<Roles>
<Role ID=\"1073741826 \" Name=\"Reader\" Description=\". ...\"
Type=\"2\" />
<Role ID=\"1073741827 \" Name=\"Publishe r\" Description=\". ...\"
Type=\"3\" />
<Role ID=\"1073741828 \" Name=\"Administ rator\" Description=\". ...\"
Type=\"1\" />
</Roles>
</GetRoleCollecti onFromUser>
i tried:
*****
// XPATH query used
string sQuery = "//d:Role[attribute::Name ='Publisher' or
attribute::Name ='Administrateu r']";
// load the complete XML node and all its child nodes into an
// XML document
XmlDocument Document = new XmlDocument();
string strXmlNodeToQue ry = "<GetRoleCollec tionFromUser xmlns=....";
Document.LoadXm l(strXmlNodeToQ uery);
// namespaces used by SharePoint and
// choosen prefix
const string DirectoryNamesp acePrefix = "d";
const string DirectoryNamesp aceURI =
"http://schemas.microso ft.com/sharepoint/soap/directory/";
// now associate with the xmlns namespaces (part of all XML
// nodes returned from SharePoint), a namespace prefix that
// we then can use in the queries
XmlNamespaceMan ager NamespaceMngr = new
XmlNamespaceMan ager(Document.N ameTable);
NamespaceMngr.A ddNamespace(Dir ectoryNamespace Prefix,
DirectoryNamesp aceURI);
// run the XPath query and return the result nodes
XmlNodeList xnRolesList = Document.Select Nodes(sQuery , NamespaceMngr);
it didn't work, my "xnRolesList.Co unt" is always equal to 0.
Any ideas ?
Thanks
Best regards
SD