XmlNamespaceManager, default namespaces, nested qualified namespace, xpath problem.

Hi,


I can't for the life of me get this to work properly. I've searched for
examples, but none of the examples quite match my environment. Here is my
XML (please treat this as immutable -- no solutions involving altering the
XML are good for me):

---- config.xml ----

<Configuration
    xmlns="urn:server:schemas:configuration"
    xmlns:f="urn:server:schemas:faq">
    <version version="0.0.0001">
        <f:faq>
            <f:section>Default</f:section>
            <f:item>
                <f:q>What is the meaning of life?</f:q>
                <f:a>42.</f:a>
            </f:item>
        </f:faq>
    </version>
</Configuration>

I want to have an XmlNode object referencing the first <faq> tag. Here is
the corresponding c# code:

XmlDocument xd = new XmlDocument();
xd.Load("config.xml");
XmlNamespaceManager xnm = new XmlNamespaceManager(xd.NameTable);
xnm.AddNamespace(String.Empty, "urn:server:schemas:configuration");
xnm.AddNamespace("f", "urn:server:schemas:faq"); // faq container namespace
XmlNode xnFaq = xd.SelectSingleNode(

"/Configuration/version[@version=\"0.0.0001\"]/f:faq[f:section=\"Default\"]"
, xnm);

This fails to select the f:faq node. I've tried using the following also:

xnm.AddNamespace("c", "urn:server:schemas:configuration");
xnm.AddNamespace("f", "urn:server:schemas:faq"); // faq container namespace
XmlNode xnFaq = xd.SelectSingleNode(

"/c:Configuration/c:version[@c:version=\"0.0.0001\"]/f:faq[f:section=\"Defau
lt\"]", xnm);

I'm beginning to lose the mind here people; any ideas? Cheers!

- Oisin





0
oising (3)
6/30/2003 10:35:18 AM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
722 Views

Similar Articles

[PageSpeed] 38

"Steven Livingstone" <s.livingstone@nospam.btinternet.com> wrote in message
news:%23MNdAXvPDHA.1748@TK2MSFTNGP11.phx.gbl...
> Have you tried this?
>
> XmlNode xnFaq = xd.SelectSingleNode(
>
> "/Configuration/version[@version='0.0.0001']/f:faq[f:section='Default']"
> , xnm);
>
> ?

Nope, that's not it. If I strip the default namespace declaration out of the
xml, e.g. the root tag is just <Configuration>, everything works fine. But
like I mentioned, this is not an option for me. Thanks for the try anyway.

- Oisin





0
oising (3)
6/30/2003 11:01:41 AM
Right -- for the benefit of the rest of the group, the problem was in the
XPath query;

if should have been:

    /c:Configuration/c:version[@version=\"0.0.0001\"] ...

instead of

    /c:Configuration/c:version[@c:version=\"0.0.0001\"] ...

I was qualifying the attribute with a namespace prefix and I didn't need to.
Guess I'd better read up a little more on schema defaults :)

- Oisin



"Oisin Grehan" <oising@nospam.iol.ie.> wrote in message
news:eEVWONvPDHA.1584@TK2MSFTNGP11.phx.gbl...
> Hi,

<snip />


0
oising (3)
6/30/2003 11:44:43 AM
ok, with the c prefix try.. (sorry not to take more time but i'm rushed of
my feet for the next couple of hours!)

"/c:Configuration/c:version[@version='0.0.0001']/f:faq[f:section='Default']"
, xnm);


"Oisin Grehan" <oising@nospam.iol.ie.> wrote in message
news:#K0N#bvPDHA.3088@TK2MSFTNGP10.phx.gbl...
>
> "Steven Livingstone" <s.livingstone@nospam.btinternet.com> wrote in
message
> news:%23MNdAXvPDHA.1748@TK2MSFTNGP11.phx.gbl...
> > Have you tried this?
> >
> > XmlNode xnFaq = xd.SelectSingleNode(
> >
> > "/Configuration/version[@version='0.0.0001']/f:faq[f:section='Default']"
> > , xnm);
> >
> > ?
>
> Nope, that's not it. If I strip the default namespace declaration out of
the
> xml, e.g. the root tag is just <Configuration>, everything works fine. But
> like I mentioned, this is not an option for me. Thanks for the try anyway.
>
> - Oisin
>
>
>
>
>


0
6/30/2003 11:51:26 AM
Reply:

Similar Artilces:

Range Naming Problems
Let me try this again. I need some expert help. I'm a battering VBA coder (beginner). How would I make the Sheet Name dynamic for this formula? I need to type the name of the sheet (Mask or any other name) in a cell, say A1, and the VBA code below ( I found it on the code here: http://www.microsoft.com/office/community/en-us/wizard.mspx?dg=microsoft.public.excel.misc&tid=9929481c-550f-4c81-a3ea-637cac37464d&cat=en-us-excel&lang=en&cr=US&sloc=en-us&m=1&query=Dynamic+combo+box&type=question&p=1) would pick it up and make the necessary changes: Private Sub...

Changing default email alias
Using Exchange 2003 SP1. We currently have email addresses in the form of jdoe@domain.com and want to change the default email address to john.doe@domain.com. Can anyone point me in the right direction here? Once the change has been made will it retro-fit all exising accounts with the new default email address or will it only be a 'point-forward' type change affecting only newly created accounts? On Fri, 3 Mar 2006 06:29:26 -0800, SilverICE <SilverICE@discussions.microsoft.com> wrote: >Using Exchange 2003 SP1. > >We currently have email addresses in the form o...

XMLNamespaceManager problem
I'm trying to query a XML file that was created via ADO.NET. My query wasn't returning anything, and I tracked the problem to an issue with the namespace that ADO.NET specified. When I remove the namespace from the XML data, the query worked. Okay, so I added code to create a XMLNamespaceManager and populate it with the namespace. Now, I'm getting this exception: Prefixes beginning with "xml" (regardless of whether the characters are uppercase, lowercase, or some combination thereof) are reserved for use by XML. At this point, the query isn't returning a...

Excel 2007 Chart Names revert to defaults
I am using Excel 2007 and have a document with many charts and a few worksheets. The document is macro enabled although there are no macros running. Periodically, when I open the document to work on it, I see that the chart names on the tabs at the bottom of the chart have changed from what I have named them back to "Chart 1", "Chart 2", "Chart 3", etc. The worksheets however, retain there names. The document is linked to a few other excel documents. Any clue on how I can stop this automatic renaming from happening? Hi, Although I have never had ...

problem importing UTF-8 txt file
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: intel I have a txt file prepared by a vendor via an automated process. It's delivered using UTF-8 character-set (accented characters, curly quotes, etc.). I'm able to open these documents fine in Word on Windows. I'm also able to open them find on the Mac with OpenOffice or TextEdit. But I cannot seem to find an option for opening such documents in Word-2008 that doesn't result in some sort of munging of non-ascii characters. A co-worker has the same issue in Mac-Word-2004. I chanced upon the following wor...

Countif Problem
I have a range of cells that I wish to check for 'data' or 'no data' entered. All I really need to know is whether a user has entered anything into any one of the cells. I am trying this formula: =COUNTIF(A1:C100,"") which works fine, returning the number of blank cells and decreasing that number by 1 each time data is entered into a previously blank cell. However, I need to invert the result. I want the formula to return 0 (zero) when all of the cells are blank, and to increment the number by 1 each time data is entered into a previously bla...

QIF file problem
I have Money 2007 Deluxe, I like to know if this works with QIF file. I have not been able to use downloaded statements for my credit card account, which comes in a QIF file format. Initiallyl it says the date format is incorrect. I then made appropriate modification to my regional setting for the date format, but now Money says the downloaded file is corrupted. On Wed, 28 Jul 2010 21:34:28 -0400, namsilat <talismana@hotmail.com> wrote: >I have Money 2007 Deluxe, I like to know if this works with QIF file. >I have not been able to use downloaded statements for my credit card >...

Problem when exporting data from mscrm
Hi, I have built an expression using the advanced tool and then ordered the results by one of the displayed columns. However, when I try to export the results to excel there is a difference between the advanced find results and what actually gets exported to excel! Has anyone else experienced this? Thanks Lee ...

POP3 Connector Delivery problem
This problem is with Exchange 2003 and when trying to relay through to an internal e-mail address which is different to the SBS2003 *.local address. The event log gives the error description as " An attempt to relay e-mail to recipient <**@netco**.co.uk> was made. The e-mail could not be delivered because the recipient's e-mail domain name does not match any local e-mail domains." Anyone any idea exactly what this is referring to? Manny wrote: > This problem is with Exchange 2003 and when trying to relay through > to an internal e-mail address which is different...

Default Tagline (Signature)
Is there a way, at the server level to add a footer or tagline to each outgoing mail message? This is exactly what I need to do for a client in the very near future. I don't know if it's possible or not, but just wanted to mention that there are others other than the two of us who would be interested in how to do this. Brian >-----Original Message----- >Is there a way, at the server level to add a footer or >tagline to each outgoing mail message? >. > ...

Problem Printing page margin borders with Publisher 2003?
I use Pub 2003, (1) 11x17 page for a 2 page layout newsletter. I have 2 computer for this, one for back-up. When I print from computer one it prints fine, if I use computer 2 it prints the margin borders around the very edge of the page. How do I get to not print that border? I have not added any border or shape on anything. Thank you for you help! same printer? with same rev. print driver? -- ~~~~~~~~~~~~~~~~~~ Rob Giordano Microsoft MVP Expression "docproc" <docproc@discussions.microsoft.com> wrote in message news:0ADFF825-466C-4D68-963E-1EA51ABF93D2@micro...

NSPI Proxy problem: MSExchangeSA and Global Catalog
sorry for my english the problem: i've shut down my 2 DC for mainteinance (in one i have Exchange 2003). after i've turn on the 2 DC (one with my exchange 2003) but i still get 3 error in application log of exchange : ID 9176 : NSPI Proxy can contact Global Catalog but it does not support the NSPI service. After a Domain Controller is promoted to a Global Catalog, the Global Catalog must be rebooted to support MAPI Clients. Reboot as soon as possible. ID 9057 : NSPI Proxy cannot contact any GC ID 9143 : Referral Interface cannot contact any Global Catalog that supports the NSPI...

Default contacts list
In 2007 how would I change the default contacts list so that whenever I select the To button I cet the Contacts folder not the Global Address Book. Thanks Ctrl+Shift+B - then Tools, Options. It's the first screenshot here: http://www.slipstick.com/tutorials/contacts/contacts.htm -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NE...

changing Default Calendar and Contacts
I was wondering if there was a way to set the default calendar and the default contacts list in Outlook to be a public Calendar and Contact list that we have using Exchange 2003? Not that I know of. James wrote: > I was wondering if there was a way to set the default > calendar and the default contacts list in Outlook to be a > public Calendar and Contact list that we have using > Exchange 2003? ...

XmlNamespaceManager, default namespaces, nested qualified namespace, xpath problem.
Hi, I can't for the life of me get this to work properly. I've searched for examples, but none of the examples quite match my environment. Here is my XML (please treat this as immutable -- no solutions involving altering the XML are good for me): ---- config.xml ---- <Configuration xmlns="urn:server:schemas:configuration" xmlns:f="urn:server:schemas:faq"> <version version="0.0.0001"> <f:faq> <f:section>Default</f:section> <f:item> <f:q>What is the mean...

Problem when customizing ISV.Config File
I have below lines in my ISV.Config file, just for testing to learn how ISV.Config works. <configuration version="3.0.5300.0"> <Entities> <Entity name="account"> <Grid> <MenuBar> <ActionsMenu> <MenuItem Title="Coming Soon..." Url="http://www.microsoft.com" WinMode="1" /> <MenuSpacer /> <SubMenu Title="Sub Test"> <MenuItem Title="Test Sub 1" Url="http://www.microsoft.com" /> <MenuSpacer /> <...

default system path
Hi all what is the default System Path folder in Exch 2003? I know that for perfomance reason you should keep the storage databases on a separate disk from the transcation logs but what about the System Path? thanks The default system path is: c:\Program Files\exchsrvr\MDBDATA I keep it on the same LUN (disk) as my SMTP logs and I haven't had a problem to-date (this is in a 5.5/2003 environment, where the MTA is utilized beyond that of a normal Native 2003 environment). Bob -- Bob Christian II MVP - LCS http://bobchristian.blogspot.com - Blog "AAFC" <nospamaa...

Can Publisher 2007 be set to save in 2000 format by default
I need to save all files created in Publisher 2007 to save inPublisher 2000 formt. Is there any way of doing this other than using "Save As" Word, Excel and Powerpoint 2007 has the feature. Does it exist in Publisher 2000. I need it to continue having documents compatible with other network users who are using Publisher 2000, XP and 2003. Probably not. The 2000 format tends to make a large file because of the way graphics used to be handled. -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "RogerL" <R...

Book1
I saved the XLT but when I get back into Excel it isn't loading th spreadsheet. It still has the old defaults. What am I doing wrong -- mdalb ----------------------------------------------------------------------- mdalby's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=705 View this thread: http://www.excelforum.com/showthread.php?threadid=26311 Did you place the file in the Excel startup folder as mentionned in my previous post? Depending on your version and OS, this folder (xlStart) may be in different places. It should be present at least in the Office...

default to bin sequenced
Hello, Great Plains 8.0 on SQL Server. We have a frustration I hope one of you out there can solve. When we print pick tickets, we ALWAYS want them to be bin sequenced. We would like that option to be selected by default when we choose to print the pick ticket. I tried to work around the issue by making the standard pick ticket sorted by bin (like it was on version 6.0) but that doesn't work now. If any of you know how to do this, I'd love to know. Our VAR gave up. Thanks. -Trevor Trevor, Is VBA/Modifier available to you? If so, respond to me at gpetrie@nebsi.com and ...

Using Normal (web) as the default style
About two times out of three, whenever I send an e-mail with Outlook 2007, the recipient sees the message quadruple-spaced between paragraphs, not double-spaced. I notice that if I select the Normal (web) style, then this problem does not occur. My question is: How do I make that style the default? I've tried saving it as a theme, but the name of my custom theme doesn't appear under Tools | Options | Mail Format... stationary. -- Michael ...

Page Setup (Default) Question
Hi, I was wondering if it was possible to have the Paper Size default to 'A4'? If so, can you please tell me how. Thanks, Christian ** Posted via: http://www.ozgrid.com Excel Templates, Training, Add-ins & Software! http://www.ozgrid.com/Services/excel-software-categories.htm ** Hi Christian haven't had too many installs of excel not stay at A4 paper when the default printer has A4 set for its paper size - you can access this under control panel / printers (or you might like to try in excel - file / print / click on the printer's properties & set it in there - but ...

CComboBox problem #2
I have a perfectly fine working application (Ap1). And a 2nd application (Ap2), that i want to use one of the dialogs from Ap1 one in. So I copied the relevant data from Ap1.rc to Ap2.rc. Plus the class files for the dialog from Ap1. (i'm not sure of the correct way to copy over a dialog). Anyway, things appeared to be working fine.. Until in OnInitDlg() ((CComboBox*)GetDlgItem(IDC_FIXANG1))->SetCurSel(0); There is an unhandled exception: _AFXWIN_INLINE int CComboBox::SetCurSel(int nSelect) { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0); ...

Problems using GetType in deserialisation
Can anyone give me a pointer as where I'm going wrong? I'm building a base class that persists to a database using serialization. GetDoc() is a base class function that reads back XML to deserialize into a new instance. The derived class needs to convert the resultant object into an instance of itself - or at least it would do except I can't get GetType to return a reference to the current running type to cast the object: Public Function GetDoc(ByVal ID As Decimal) Dim xs As XmlSerializer Dim rdr As StringReader = Me.ReadDBString(ID) Dim obj As Ob...

default preview pane closed
We are running windows server 2003, with workstations running windows 2000 and outlook 2000,2002, and 2003. We need to turn off the preview pane as default for all folders. Any idea how to do this? ...