Hi,
How can i get all the nodes with attribute Name = "Publisher" or
Name="Administrator" using XPath query and C# for this xml doc?
<GetRoleCollectionFromUser
xmlns=\"http://schemas.microsoft.com/sharepoint/soap/directory/\">
<Roles>
<Role ID=\"1073741826\" Name=\"Reader\" Description=\"....\"
Type=\"2\" />
<Role ID=\"1073741827\" Name=\"Publisher\" Description=\"....\"
Type=\"3\" />
<Role ID=\"1073741828\" Name=\"Administrator\" Description=\"....\"
Type=\"1\" />
</Roles>
</GetRoleCollectionFromUser>
i tried:
*****
// XPATH query used
string sQuery = "//d:Role[attribute::Name='Publisher' or
attribute::Name='Administrateur']";
// load the complete XML node and all its child nodes into an
// XML document
XmlDocument Document = new XmlDocument();
string strXmlNodeToQuery = "<GetRoleCollectionFromUser xmlns=....";
Document.LoadXml(strXmlNodeToQuery);
// namespaces used by SharePoint and
// choosen prefix
const string DirectoryNamespacePrefix = "d";
const string DirectoryNamespaceURI =
"http://schemas.microsoft.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
XmlNamespaceManager NamespaceMngr = new
XmlNamespaceManager(Document.NameTable);
NamespaceMngr.AddNamespace(DirectoryNamespacePrefi x,
DirectoryNamespaceURI);
// run the XPath query and return the result nodes
XmlNodeList xnRolesList = Document.SelectNodes(sQuery , NamespaceMngr);
it didn't work, my "xnRolesList.Count" is always equal to 0.
Any ideas ?
Thanks
Best regards
SD