#### xpath query #4

I’m trying to pull up a NodeList of all the Grant elements in the
AccessControlList element of the xml document displayed below.  However I’m
not getting the list using the following code:

XmlDocument doc = new XmlDocument();
XmlNodeList nodes =
doc.SelectNodes("/AccessControlPolicy/AccessControlList");

What am I missing?

Scott

My Xml:

<?xml version="1.0" encoding="UTF-8" ?>
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Owner>
<ID>xxxxxxxxxxxxxxxxxxxx</ID>
</Owner>
<AccessControlList>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="CanonicalUser">
<ID>xxxxxxxxxxxxxxxxxxxx</ID>
</Grantee>
<Permission>FULL_CONTROL</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
<Permission>WRITE</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
</Grant>
</AccessControlList>
</AccessControlPolicy>


 0
M1iS (10)
10/6/2008 9:10:11 PM
dotnet.xml 7266 articles. 0 followers.

4 Replies
730 Views

Similar Articles

[PageSpeed] 23

Hi,

> What am I missing?
1. Defining XmlNamespaceManager
var xmlNM = new XmlNamespaceManager(doc.NameTable);
2. Matching your own default namespace with a certain prefix, e.g. 'def'
3. Using defined prefix in query (including Grant if needed)
doc.SelectNodes("/def:AccessControlPolicy/def:AccessControlList/def:Grant",
xmlNM);

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com

> I’m trying to pull up a NodeList of all the Grant elements in the
> AccessControlList element of the xml document displayed below.
> However I’m not getting the list using the following code:
>
> XmlDocument doc = new XmlDocument();
> XmlNodeList nodes =
> doc.SelectNodes("/AccessControlPolicy/AccessControlList");
> What am I missing?
>
> Scott ...


 0
ameleta (7)
10/6/2008 11:56:48 PM
Thank you, that did the trick.

"Alex Meleta" wrote:

> Hi,
>
> > What am I missing?
> 1. Defining XmlNamespaceManager
>       var xmlNM = new XmlNamespaceManager(doc.NameTable);
> 2. Matching your own default namespace with a certain prefix, e.g. 'def'
> 3. Using defined prefix in query (including Grant if needed)
>      doc.SelectNodes("/def:AccessControlPolicy/def:AccessControlList/def:Grant",
> xmlNM);
>
> Regards, Alex Meleta
> [TechBlog] http://devkids.blogspot.com
>
> > I’m trying to pull up a NodeList of all the Grant elements in the
> > AccessControlList element of the xml document displayed below.
> > However I’m not getting the list using the following code:
> >
> > XmlDocument doc = new XmlDocument();
> > XmlNodeList nodes =
> > doc.SelectNodes("/AccessControlPolicy/AccessControlList");
> > What am I missing?
> >
> > Scott ...
>
>
>

 0
M1iS (10)
10/7/2008 12:58:29 AM
Another question, how do I go about accessing the values of the attributes in
the Grant nodes?  The attributes property of the individual nodes are empty.

"Alex Meleta" wrote:

> Hi,
>
> > What am I missing?
> 1. Defining XmlNamespaceManager
>       var xmlNM = new XmlNamespaceManager(doc.NameTable);
> 2. Matching your own default namespace with a certain prefix, e.g. 'def'
> 3. Using defined prefix in query (including Grant if needed)
>      doc.SelectNodes("/def:AccessControlPolicy/def:AccessControlList/def:Grant",
> xmlNM);
>
> Regards, Alex Meleta
> [TechBlog] http://devkids.blogspot.com
>
> > I’m trying to pull up a NodeList of all the Grant elements in the
> > AccessControlList element of the xml document displayed below.
> > However I’m not getting the list using the following code:
> >
> > XmlDocument doc = new XmlDocument();
> > XmlNodeList nodes =
> > doc.SelectNodes("/AccessControlPolicy/AccessControlList");
> > What am I missing?
> >
> > Scott ...
>
>
>

 0
M1iS (10)
10/7/2008 5:53:01 AM
Nevermind that last question, I figured out what I was doing wrong.

"Alex Meleta" wrote:

> Hi,
>
> > What am I missing?
> 1. Defining XmlNamespaceManager
>       var xmlNM = new XmlNamespaceManager(doc.NameTable);
> 2. Matching your own default namespace with a certain prefix, e.g. 'def'
> 3. Using defined prefix in query (including Grant if needed)
>      doc.SelectNodes("/def:AccessControlPolicy/def:AccessControlList/def:Grant",
> xmlNM);
>
> Regards, Alex Meleta
> [TechBlog] http://devkids.blogspot.com
>
> > I’m trying to pull up a NodeList of all the Grant elements in the
> > AccessControlList element of the xml document displayed below.
> > However I’m not getting the list using the following code:
> >
> > XmlDocument doc = new XmlDocument();
> > XmlNodeList nodes =
> > doc.SelectNodes("/AccessControlPolicy/AccessControlList");
> > What am I missing?
> >
> > Scott ...
>
>
>

 0
M1iS (10)
10/7/2008 6:10:01 AM

Similar Artilces:

Interactive Web database with query capabilty
I see lots of questions about using Access as an interactive web database but many of the answers seem to dance all around the question. Let me be as precise with the question as possbile... Here is a online database that is exactly like what I want to do with Access http://www.osalt.org/events/osalt http://www.osalt.org/events/submit This interface was created with something called Ruby on Rails. (1) Can this same thing be done with Access and asp? (2) Can you provide an example of an access database that offers the same query capability and submission capability? I have done a si...

XPath
Using XPath I am querying parts of XML document, " get quoted by \ - is it possible to specify not to quote " with \? <RootElement> <Element Attribute="SomeValue" /> </RootElement> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); XmlNode xmlNode = xmlDoc.SelectSingleNode("//RootElement/Element") Print xmlNode.OuterXml <Element Attribute=\"SomeValue\"/> where I was expecting to get <Element Attribute="SomeValue"/> TIA Dennis wrote: > Using XPath I am querying parts of XML document,...

Getting a specific parent of any node via xpath navigation

Failure sending an email from CRM 4.0
Hi everybody, We are using CRM Dynamics 4.0 and we are facing a problem when a workflow tries to send an email, it's kind of weird because yesterday was working properly. I tried to get trough checking the Exchange but the CRM is allowed to send Emails so that is working properly I guess. Also I've restarted the Email Router service and I get the same error. And finally I've changed in the Microsoft.Crm.Tools.EmailAgent.xml file the SchedulingPeriod from 1000 to 30 but nothing happens. I found many errors from the MSCRMEmail source in the Event Viewer and the error descri...

When i have read new incoming messages, the messages stay unread (enveloppe closed). I don't know how to solve this. I use Outlook 2000. You might try this. Open Outlook and click on Tools >Options. In the dialog box that opens up click on the Read tab. Make sure there is a checkmark in the box that says "Mark messages read after displaying for ? second(s). Also put a number in the duration box, something like 3 or 5 seconds. Click Apply, Click OK. "Pbos" <anonymous@discussions.microsoft.com> wrote in message news:34bd01c4a526$50f17c00$a301280a@phx.gb...

Excel Query #3
I have a large excel spreadsheet that contains skills and skill levels of consultants. Is it possible to create some kind of form within Excel that has a Skills drop down box at the top. When you select the skill you require it looks at the data and displays only the people who have that skill and the skill level? Thanks, Hi, Alison. Try the autofilter feature; it should work perfectly for your needs: http://www.officearticles.com/excel/using_autofilter_in_microsoft_excel.htm ************ Anne Troy www.OfficeArticles.com "Alison" <Alison@discussions.microsoft.com> wrot...

How to Avoid Dividing by 0 errors in query
I have been getting 'Overflow' errors when trying to run a query. I found out it is because some of my data has a divisor of 0 (e.g. 10/0). This data comes from linked Excel worksheets with hundreds of rows of data. Is there an IF statement or something I can add to the query in the dividing column that can just return a blank (instead of the #Error)? I need this query to feed into another query that I am getting the 'Overflow' error on. Iif([Divisor]=0,0,[MyField]/[Divisor]) MH "Jason52" <Jason52@discussions.microsoft.com> wrote in message news:8DA...

Delete Queries using Unmatched Query
Reading many helpful responses on this site, but unfortunately none of them seem to remedy my current issue. Just learning Access, took a quick college prep course, got the basics. Now I am expanding freelance. SO the scenarios is my test idea that I have intent to apply on larger scale. I have a database with 15 records... lets say reservations (tbl_reservations) for a hotel. Used a maketable to copy that table because it gets updated often to cancelled or complete status. So I filter out the 9 of those 15 reservations which are still in pending status and make the new table (tbl...

XPath pb
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the DOM.xml property : <?xml version="1.0" ?> <?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\manifest.xsf\" solutionVersion=\"1.0.0.9\" initialView=\"messagesList\" ?> <?...

How to pass a Nodeset to an XPath extension function?
I am using the .NET framework v2.0.40607 with Visual C# Express and I would like to create some custom XPath functions to use directly in a XSLT stylesheet. I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object) to register the functions I've written. The functions that take a String, Boolean or Number parameter work perfectly. However, I do not know how to create a function that will accept a Nodeset as a parameter. I tried writting a function taking a XPathNavigator object, but it does not work for all XPath queries that return a Nodeset: I get an error &qu...

Query/Report Question
I am creating a construction diary database and I am having some difficulty calculating my number of working days, and would appreciate any insight into what I need to do. I have a fixed beginning date (notice to proceed date) that I have in a table related to other project information. In a data entry form I have a check box to be used if the work day will not be counted (noworkday). I know the formula for the will be working days = report date - beginning date + sum of noworkday. My report will be based on a date range, so how can get the sum of noworkday for each date of the repo...

Can I have in Excel SQL query computed constants like "? as Col1"
Trying to have a query that can set a constant in the select statement, for example: SELECT Author, '11/15/2005' as Updated, PublishDate FROM Author WHERE Author like 'A*' Can I prompt the user for this value as an input, for example: SELECT Author, ? as Updated, PublishDate FROM Author WHERE Author like 'A*' Maybe with a prompt "Please enter Updated date". Before resorting to VBA or Access, just want to see if it can be done in Excel. ...

Send on behalf #4
How can I control what Sent Items folder messages are delivered to. If I send on behalf of someone I would like the mail to stay in their Sent Items and not mine. If the person receiving the sent on behalf email replies, the reply will end up in my mailbox and not the mailbox I sent on behalf. Is there a way to control this ? On Thu, 22 Dec 2005 03:11:02 -0800, RogGen <RogGen@discussions.microsoft.com> wrote: >How can I control what Sent Items folder messages are delivered to. If I send >on behalf of someone I would like the mail to stay in their Sent Items and >not mi...

I want to add this to my Query: if [tblHorseInfo,Status] shows "Finished" to show "Finished" In [TableHorseInfo,StatusDate] SELECT tblHorseInfo.HorseID, tblHorseInfo.Status, funGetHorse(0,tblHorseInfo.HorseID,True) AS Expr1, funGetHorse(0,tblHorseInfo.HorseID,False) AS Name, funGetHorse(0,tblHorseInfo.HorseID,False) AS Expr2, tblHorseInfo.Invocing, tblHorseInfo.StatusDate FROM tblHorseInfo ORDER BY tblHorseInfo.Status, funGetHorse(0,tblHorseInfo.HorseID,True); Thanks for any help on this...............Bob Bob, there is a problem here with data types. If you ...

Run query before closing database
I am using Access 2002. I have a user who needs to do Adhoc reporting and I want to keep her out of my tables. I have a macro that runs on the AutoExec to transfer the database tables from the original to a new database so she can do whatever she wants to create reports. I also have a SQL that will drop all the tables when it's run. I don't want the user to be responsible for running this query. I just want it to run when she closes the database. Is this possible? Is there something on close like the AutoExec on opening a database? Thanks for the help. Ann wrote...

Dates in a form for filtering Report query
I have a form "Period" with two text boxes. One for startDate and one for EndDate. I want to use that form to limit the query for my Report by the dates. However, when I refer to the Form it does not seem to understand it is a date? I use the following statement in my query: SELECT Opphold.CheckIn FROM Opphold WHERE (((Opphold.CheckIn)<=[Forms]![Perioder].[txtStartDate])); I also tried to convert it to a date like the following: CDate(<=[Forms]![Perioder].[txtStartDate]))) but that did not work? What should I do in order to the query to read the condition or dat...

Unable to add a new contact in CRM 4.0
Hi all Unable to add a new contact in CRM 4.0 as it errors out saying "Object reference not set to an instance of an object". Here is the event log information. Web Service Plug-in failed in OrganizationId: 01f0210d-6bf6-4c27-8919-00eccab73e2d; SdkMessageProcessingStepId: ab0fa3e5-3ceb-dc11-8840-0003ffbb159c; EntityName: contact; Stage: 50; MessageName: Create; AssemblyName: AlertCRM40Plugin.CRM40PostPlugIn, AlertCRM40Plugin, Version=1.0.0.0, Culture=en-US, PublicKeyToken=4406fa73b5445f20; ClassName: AlertCRM40Plugin.CRM40PostPlugIn; Exception: Unhandled Exception: System....

Problem with Outlook 2003 #4
For some reason I cannot access my Inbox folder any more. A message appears ' <Path of pst file> Unable to access .pst, Invalid Handle'. and when I try to copy the pst file somewhere else I get a 'cyclic redundancy check' error. Even if I try to delete a few files I get the same message, can anyone help me out, its urgent. Thanks Your PST is probably corrupt. Check out the "Inbox Repair Tool", "Scan Inbox", or SCANPST tool, depending on your version of Outlook. You may or may not lose some data, but under most circumstances the tool can put you ...

XPath Validation
I'm looking for a way to Validate an XPath prior to executing the expression, without using a try catch clause. For example: I'm looking for something that would tell me that "\some/Xpath\to\Node" is invalid... Any Ideas? Hi, As far as I know, the .NET framework could not validate XPath directly with class library. The only thing we can do is to use try/catch block. Or you can try to find some 3rd-party tool such as XML spy to validate it. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Thanks K...

Xpath with namespaces
Hello Everyone, I am having an issue with xml and namespaces, at least I think it is namespaces. When I use namespaces, I cannot use SelectSingleNode / SelectNodes as they always return 0/Nothing respectively. Anyone have any thoughts? Thanks in advance VB.Net 2005 WinXP Sp2 Test code: Dim objXML As System.Xml.XmlDocument 'Test XML 1 ==> Always returns 0 objXML = New System.Xml.XmlDocument objXML.Load(Application.StartupPath & "\xmlfile1.xml") MsgBox(objXML.SelectNodes("top/middle").Count) 'Test XML 2 ==> Always re...

Access 2003 Mail Merge to Word 2003 using query to locate the specific record being displayed
After spending ALL DAY searching the entire WEB I have found a lot of posts asking this same question but not one answer. I thought I's throw it up again. The button on my form does this. * From Mergit() * Dim objWord As Word.Document Set objWord = GetObject("H:\Contract Admin Database\Merge Documents \WIP\Closings\Closing Packet Documents\Test - closing packet EM.doc", "Word.Document") objWord.Application.Visible = True ' Set the mail merge data source as the Northwind database. objWord.MailMerge.OpenDataSource _ Name:="H:\Contract Adm...

Installation Problem #4
After installing Publisher 2003, every time I open it or even open a previously made document (from Publisher 200), a grey box comes up with installer instructions, loading installation information, and after about 2 minutes of this, the document finally opens. Since it is installed on the hard drive of the computer, how can this delay be eliminated. I work on a networked computer system, and no one else in the office has this problem! I have also tried a fix of: installing it, opening a document with the installation CD in the drive, and it still didn't work. Thank you for y...

Print area query
Hi I am trying to print a page, the top margin is .18 and header 0, the bottom margin is o & footer zero but when i give print in paper the bottom margin is left more than top margin, i want to push bottom a little more but when i do, the content moves to next page, any solution for this? -- Life isa journey not a destination The problem is how close to the buttom your printer can print. Do not expect that you can print as close to the bottom as to the top of the paper. Regards, Per "Sherees" <Sherees@discussions.microsoft.com> skrev i meddelelsen n...

Tricky XPath query
Hi all, I've just changed the structure of my XML file and now I need to construct an XPathNavigator object that uses tags from two different levels in the XML file. For example: <someTag> <innerTagA> <innerInnerTagA> <innerInnerInnerTagA> Some Data That Belongs Here </innerInnerInnerTagA> <innerInnerInnerTagB> Some Data that Belongs More Specifically Here </innerInnerInnerTagB> </innerInnerTagA> <innerInnerTagB> <innerInnerInnerTagZ> This Data should real...

Obtaining the correct results from a two table query
I have two tables say A and B, what I am trying to achieve with the query is just to display records that have the received field ticked in table A and the colour field in table B not containing �Y�. How do I modify the code below to achieve this? SELECT A_Date, A.Received, A.ID, B. Colour FROM A LEFT JOIN B ON DDP_A.Main = B.Main WHERE (((A.Received)= -1) AND ((B.Colour <> �Y�)); jo@jo.uk wrote: >I have two tables say A and B, what I am trying to achieve with the query is >just to display records that have the received field ticked in table A and >the colo...