XPath problem with two xmlns

I have got file  raport.rld which is an XML file generated by MS Reporting
Services.

The problem is:

in this file are tags from two different namespaces

xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
tion"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"



 when I'm trying to use XPATH to get <teble> tag it doesn't work. (the
result is empty)

 I've removed All tegs like

<rd:TypeName>System.Int32</rd:TypeName>

Now all is working fine but what to do when I have tags from two different
namespaces?

I don't want to remove all tags from second namespace.



Tom.



0
4/1/2004 11:21:53 AM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
974 Views

Similar Articles

[PageSpeed] 38


Gismo wrote:

> I have got file  raport.rld which is an XML file generated by MS Reporting
> Services.
> 
> The problem is:
> 
> in this file are tags from two different namespaces
> 
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> tion"
> xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
> 
> 
> 
>  when I'm trying to use XPATH to get <teble> tag it doesn't work. (the
> result is empty)
> 
>  I've removed All tegs like
> 
> <rd:TypeName>System.Int32</rd:TypeName>
> 
> Now all is working fine but what to do when I have tags from two different
> namespaces?

You need to declare a prefix for every namespace and then use the prefix 
in your XPath expression. How you do that depends on the environment, if 
you use XPath inside of an XSLT stylesheet you can simply declare the 
prefixes with
   <xsl:stylesheet
 
xmlns:rd="xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
and then use
   rd:TypeName
in your XPath expression.

If you are using an API like selectNodes/selectSingleNode then you need 
to call
   xmlDocument.setProperty("SelectionNamespaces",
 
"xmlns:rd='http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'")

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/

0
mahotrash (1778)
4/1/2004 2:09:40 PM
Uzytkownik "Martin Honnen" <mahotrash@yahoo.de> napisal w wiadomosci
news:OqLc8L$FEHA.692@TK2MSFTNGP09.phx.gbl...
>
>
> Gismo wrote:
>
> > I have got file  raport.rld which is an XML file generated by MS
Reporting
> > Services.
> >
> > The problem is:
> >
> > in this file are tags from two different namespaces
> >
> >
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> > tion"
> >
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
> >
> >
> >
> >  when I'm trying to use XPATH to get <teble> tag it doesn't work. (the
> > result is empty)
> >
> >  I've removed All tegs like
> >
> > <rd:TypeName>System.Int32</rd:TypeName>
> >
> > Now all is working fine but what to do when I have tags from two
different
> > namespaces?
>
> You need to declare a prefix for every namespace and then use the prefix
> in your XPath expression. How you do that depends on the environment, if
> you use XPath inside of an XSLT stylesheet you can simply declare the
> prefixes with
>    <xsl:stylesheet
>
>
xmlns:rd="xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportd
esigner"
> and then use
>    rd:TypeName
> in your XPath expression.
>
> If you are using an API like selectNodes/selectSingleNode then you need
> to call
>    xmlDocument.setProperty("SelectionNamespaces",
>
>
"xmlns:rd='http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'"
)
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>
There is no method like setProperty.
My example code is:

My example code is:
using System;
using System.IO;
using System.Xml;
public class Sample
{
    public static void Main()
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("c:/tab2.xml");

        XmlElement root = doc.DocumentElement;

        XmlNodeList nodeList;
        nodeList = root.SelectNodes("//Table");
        if (nodeList != null)
        foreach (XmlNode s1 in nodeList)
        {
            try
            {
                Console.WriteLine(s1.Name);
            }
            catch (XmlException e) {
                Console.WriteLine(e.Message);
            }
        }
    }
}




Gismo.



0
4/2/2004 9:08:48 AM

Gismo wrote:

> Uzytkownik "Martin Honnen" <mahotrash@yahoo.de> napisal w wiadomosci
> news:OqLc8L$FEHA.692@TK2MSFTNGP09.phx.gbl...
> 
>>
>>Gismo wrote:
>>
>>
>>>I have got file  raport.rld which is an XML file generated by MS
> 
> Reporting
> 
>>>Services.
>>>
>>>The problem is:
>>>
>>>in this file are tags from two different namespaces
>>>
>>>
> 
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> 
>>>tion"
>>>
> 
> xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
> 
>>>
>>>
>>> when I'm trying to use XPATH to get <teble> tag it doesn't work. (the
>>>result is empty)
>>>
>>> I've removed All tegs like
>>>
>>><rd:TypeName>System.Int32</rd:TypeName>
>>>
>>>Now all is working fine but what to do when I have tags from two
> 
> different
> 
>>>namespaces?
>>
>>You need to declare a prefix for every namespace and then use the prefix
>>in your XPath expression. How you do that depends on the environment, if
>>you use XPath inside of an XSLT stylesheet you can simply declare the
>>prefixes with
>>   <xsl:stylesheet
>>
>>
> 
> xmlns:rd="xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportd
> esigner"
> 
>>and then use
>>   rd:TypeName
>>in your XPath expression.
>>
>>If you are using an API like selectNodes/selectSingleNode then you need
>>to call
>>   xmlDocument.setProperty("SelectionNamespaces",
>>
>>
> 
> "xmlns:rd='http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'"
> )
> 

> There is no method like setProperty.

Sorry, I thought you might be using MSXML but you use .NET, there indeed 
is no such method.

With .NET you need an XmlNamespaceManager and declare the prefixes for 
your XPath expressions and then pass that manager to the SelectNodes method.
For instance with the example document being

<?xml version="1.0" encoding="UTF-8"?>
<gods xmlns="http://vatican.va/2004/gods">
   <god name="Kibo" />
   <god name="Jaffo" />
   <dv:devil xmlns:dv="http://vatican.va/2004/devils" name="Xibo" />
</gods>

the following successfully queries the document using XPath

using System;
using System.Xml;

public class Test20040402 {
   public static void Main (string[] args) {
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.Load(@"test20040402.xml");
     XmlNamespaceManager namespaceManager = new 
XmlNamespaceManager(xmlDocument.NameTable);
     namespaceManager.AddNamespace("gs", "http://vatican.va/2004/gods");
     namespaceManager.AddNamespace("dv", "http://vatican.va/2004/devils");
     XmlNodeList gods = xmlDocument.SelectNodes("/gs:gods/gs:god", 
namespaceManager);
     Console.WriteLine("Found {0} elements.", gods.Count);
     foreach (XmlNode node in gods) {
       Console.WriteLine(node.Name);
     }
     gods = xmlDocument.SelectNodes("/gs:gods/dv:devil", namespaceManager);
     Console.WriteLine("Found {0} elements.", gods.Count);
     foreach (XmlNode node in gods) {
       Console.WriteLine(node.Name);
     }
   }

}
-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/

0
mahotrash (1778)
4/2/2004 10:43:58 AM
Thanx, it works fine now.
:-)

Gismo.



Uzytkownik "Martin Honnen" <mahotrash@yahoo.de> napisal w wiadomosci
news:#T5Ir9JGEHA.1240@TK2MSFTNGP10.phx.gbl...
>
>
> Gismo wrote:
>
> > Uzytkownik "Martin Honnen" <mahotrash@yahoo.de> napisal w wiadomosci
> > news:OqLc8L$FEHA.692@TK2MSFTNGP09.phx.gbl...
> >
> >>
> >>Gismo wrote:
> >>
> >>
> >>>I have got file  raport.rld which is an XML file generated by MS
> >
> > Reporting
> >
> >>>Services.
> >>>
> >>>The problem is:
> >>>
> >>>in this file are tags from two different namespaces
> >>>
> >>>
> >
> >
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini
> >
> >>>tion"
> >>>
> >
> >
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
> >
> >>>
> >>>
> >>> when I'm trying to use XPATH to get <teble> tag it doesn't work. (the
> >>>result is empty)
> >>>
> >>> I've removed All tegs like
> >>>
> >>><rd:TypeName>System.Int32</rd:TypeName>
> >>>
> >>>Now all is working fine but what to do when I have tags from two
> >
> > different
> >
> >>>namespaces?
> >>
> >>You need to declare a prefix for every namespace and then use the prefix
> >>in your XPath expression. How you do that depends on the environment, if
> >>you use XPath inside of an XSLT stylesheet you can simply declare the
> >>prefixes with
> >>   <xsl:stylesheet
> >>
> >>
> >
> >
xmlns:rd="xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportd
> > esigner"
> >
> >>and then use
> >>   rd:TypeName
> >>in your XPath expression.
> >>
> >>If you are using an API like selectNodes/selectSingleNode then you need
> >>to call
> >>   xmlDocument.setProperty("SelectionNamespaces",
> >>
> >>
> >
> >
"xmlns:rd='http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'"
> > )
> >
>
> > There is no method like setProperty.
>
> Sorry, I thought you might be using MSXML but you use .NET, there indeed
> is no such method.
>
> With .NET you need an XmlNamespaceManager and declare the prefixes for
> your XPath expressions and then pass that manager to the SelectNodes
method.
> For instance with the example document being
>
> <?xml version="1.0" encoding="UTF-8"?>
> <gods xmlns="http://vatican.va/2004/gods">
>    <god name="Kibo" />
>    <god name="Jaffo" />
>    <dv:devil xmlns:dv="http://vatican.va/2004/devils" name="Xibo" />
> </gods>
>
> the following successfully queries the document using XPath
>
> using System;
> using System.Xml;
>
> public class Test20040402 {
>    public static void Main (string[] args) {
>      XmlDocument xmlDocument = new XmlDocument();
>      xmlDocument.Load(@"test20040402.xml");
>      XmlNamespaceManager namespaceManager = new
> XmlNamespaceManager(xmlDocument.NameTable);
>      namespaceManager.AddNamespace("gs", "http://vatican.va/2004/gods");
>      namespaceManager.AddNamespace("dv", "http://vatican.va/2004/devils");
>      XmlNodeList gods = xmlDocument.SelectNodes("/gs:gods/gs:god",
> namespaceManager);
>      Console.WriteLine("Found {0} elements.", gods.Count);
>      foreach (XmlNode node in gods) {
>        Console.WriteLine(node.Name);
>      }
>      gods = xmlDocument.SelectNodes("/gs:gods/dv:devil",
namespaceManager);
>      Console.WriteLine("Found {0} elements.", gods.Count);
>      foreach (XmlNode node in gods) {
>        Console.WriteLine(node.Name);
>      }
>    }
>
> }
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>


0
4/2/2004 12:26:06 PM
Reply:

Similar Artilces:

EXCEL 2000 problem
I am having an intermittent problem with EXCEL 2000. Normally I can drag a formula across several columns and it will produce the correct answer for each column. Currently, when I drag the formula across, although the formula appears to be correct, the same total appears in every column, regardless of the content of the column.The total is the same as the column from where I dragged the formula. Also, if I change a column entry, the total will not update. This is causing some concern as I have to manully enter every formula and after I change an entry, I have to manuall repeat the ...

M2004 (No MSN, no Passport) -> M2006 Any problems?
I use M2004 without MSN, Passport or passwords. My financial institutions (Citi cards, Fidelity, Bank One) download into M2004 without any problems. Will I be able to transition into M2006 without any problems? I'll be happy to maintain the current M2004 features and capabilities. I'm thinking of M2006 only because the on-line stuff for M2004 will expire next year. -- Aloke ---- to reply by e-mail remove 123 and change invalid to com In microsoft.public.money, Aloke Prasad wrote: >I use M2004 without MSN, Passport or passwords. My financial institutions >(Citi card...

keyboard shortcuts problem
Certain keyboard shortcuts have stopped working in my Excel 2003. CTRL+X, CTRL+C, and CTRL+V no longer work. They still work from the toolbar menu or when right clicking. Other shortcuts like CTRL+A and CTRL+Z still work. Does anyone have any ideas? -- carloscuderia ------------------------------------------------------------------------ carloscuderia's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=34503 View this thread: http://www.excelforum.com/showthread.php?threadid=542700 Do those shortcut keys work in other applications? If yes, maybe you have a ...

Problem with Outlook 2003 w/BCM
In Outlook you are able to type names into the To: list and go about your business. All of a sudden I can type the names in or the distribution list name but it won't allow me to send the email saying it has a problem with the parameters. If I select the name or DL name from the actual address book it works fine. Anyone else had this problem or know what might be causing the problem. It's on a XP Pro laptop. Thanks in advance. JD Try this: Close Outlook Search for a file with an NK2 extension. It should be in C:\Documents and Settings\Application Data\Microsoft\Outlook Renam...

Junk mail filter instillation problem
The operating system is Windows XP Home with all the Microsoft updates. The office program also is current, with one major exception. I bought a copy of Outlook 2003 some time a ago, and installed it in place of Outlook 2002. I have been unsuccessful in attempting to install over and over again the recently released December 2005 junk mail filter update. I even shut down the Kaspersky anti-virus and the Outpost firewall in some of my attempts to install this update. How do I install this latest junk mail filter. Thanks ...

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,...

Italics problem
I notice when I go to format cells, if I switch to italic bold bold italic Then it is impossible to switch back to "Regular". "Regular" does not seem to be an option. Help, everything is in italics!! ...

Problems with clicking in a tree ctrl.
Hello! Strange thing here. I tried to click at the plus sign in a tree, but I can't receive the selected item. why? -- - Lars ...

Problem Converting from Money 2003 to 2007
Hi everyone. We have been using Money 2003 Deluxe (V. 11) for several years, and have been with Money even prior to that. After several notifications that our version is no longer being supported, we have decided to move to the newest version, Money 2008 Plus Deluxe. Both are the US versions of the software. The 2003 has been running on a number of XP systems, and one Vista PC. As context, we consider ourselves relatively advanced users. We're relatively competent with PCs, as well accounting software. We move data around all the time, and know how to back it up. We have a large f...

delegate problems
If I'm a delegate for someone and I have his inbox and I go and delete something it goes to my delete folder not his. Is there a way to setup a rule or something so when I delete something from his in box it would show up in his delete folder. ...

Strange Message in Header and red x problem
My continuing Saga of the red x's. When an E-mail (that has http tags in it that will show as red x's when read) arrives into Outlook 2007 (with Vista Ultimate OS and Office Pro 2007 installed)), the header in the top pane first shows the message : "You have received an HTML E- Mail from sendersname, but it appears that your E-Mail client is set to read messages in plain text" Well, my client is NOT set to do that (or anywhere I can see) and after you hover over the message with the mouse, that header disappears and it shows just the subject line. Does that help anyone tow...

Getting a specific parent of any node via xpath navigation
I am storing my site structure as such: <menuItems> <menuItem> <pageID>1</pageID> </menuItem> <menuItem> <pageID>2</pageID> <menuItem> <pageID>4</pageID> <menuItem> <pageID>5</pageID> <menuItem> <pageID>6</pageID> </menuItem> </menuItem> </menuItem> </menuItem> <menuItem> <pageID>3</pageID> ...

email delivery problem
Hi, Since upgrading to a new DSL line we started to recieve complaints from users that email to aol and a number of other addresses were not being delivered. Further investigation found that aol was rejecting our ip address because it deemed it to be dynamic - this is not the case as we paid for a static allocation. We have contacted our isp and they confirm that the addresses are static but were part of a dynamic allocation thus explaining why aol and others are blocking email. They suggested relaying mail through one of their mail servers, however I have been unable to find where this ca...

problems in HQ
Hi, I have a multitore scenario....... one of my stores are showing a batch being opened and closed, but at my Head Office i am not seeing that batch in HQ. If anyone else had this problem please send me the solution. Thanks. -- Kay Hi Kay - try creating a 401 worksheet, backdate it a day or two before the date of the batch at the store and connect with your store - this should bring in the batch into HQ...hope this helps. "Kay" wrote: > Hi, > I have a multitore scenario....... one of my stores are showing a batch > being opened and closed, but at my Head Office i...

Money 2004
I have multiple accounts at Fidelity (Brokerage, 401(k), IRAs, UTMA) in my and my spouse's name. My problem is that Money 2004 inexplicably stops downloading transactions from the Fidelity accounts. It will still update online quotes, and credit card transactions from Discover. The only way I can download Fidelity transactions is to go to the Online Service Manager and discontinue using the service, and then go back to setup service. This becomes a pain when you have to do it every two weeks and then you have to match each account in Money with the corresponding Fidelity accou...

Same problem can send mail but cant recieve none of the threads he
My problem is basiclly the same but i tried all that and it didnt help im tryign to make my windowmail read my live account and it will recieve email but not send or forward here is my error code The connection to the server has failed. Subject 'test', Account: 'pop3.live.com', Server: 'smtp.live.com', Protocol: SMTP, Port: 25, Secure(SSL): Yes, Socket Error: 10060, Error Number: 0x800CCC0E Try these - compare against the settings you currently have in Tools - Accounts - Properties for that account. Live.com Settings: Server names and ports: POP3 ...

Installation problem 06-04-07
I am trying to install CRM from the 90day demo provided with "Working with Microsoft Dynamics CRM 3.0" and get the followin message:- Microsoft CRM 3.0 Server Setup Action Microsoft.Crm.Setup.Common.Analyzer+CollectAction failed, The specified domain either does not exist or could not be contacted. with Abort/Retry/Ignore buttons I am completely new to CRM so this may be obvious - but not to me... Guy Hi Does the server you are using to install CRM on belong to the domain that you are using? Does the install user account have rights to the domain? -- Rgds Michael MCDB...

data range problem
Hi I have a problem with external data. In the Data Range Properties, under Data Layout. There are 3 options after 'If the number of rows in the data range changes upon refresh:' 1 - Insert cells for new data, delete unused cells 2 - Insert entire rows for new data, clear unused cells 3 - Overwrite existing cells with new data, clear unused cells. I want option 3 to be the default oprion but it always defaults back to option 2. Is there any way I can change this.?? Cheers Baz ...

Problems and more problems with exchange 2003 sbs
Today I reboot the our server, this is the first occasion after install a patch (that the windows has downloaded automatically) before few days. In 1 hour i received a message that the C: drive is full (yesterday I has 7GB free space) . surprised and checking the problem, I receive in my workstation a message that the outlook is not conected to the server. I seen that the mdadata folder has same hundreds of logs of 5MB size!!! After I move a lot of them to another location the exchange fill the free space with new logs...I change the configuration to make a circular logs and i moved a few hu...

Resource DLL problem
Hi, Anybody encoutered this issue? I'm using VC++ 6.0 to create a resource DLL, it works fiine. Later, I add a static text control and give it ID as IDC_STATIC_MY, then I rebuild it . It seems to work fine but actually this control can't be called by application. I check the resource.h file of DLL project and found this ID is not there, so I add it and rebuild again. A warning appears saying this ID has been redefiined. However, this DLL can be called successfully by other application. Just want to know how to eliminate this warning in building process. -- Best regards. Susan ...

OnKeyDown() Problems
Hi guys, My CWnd-derived view (non doc-view architecture) isn't getting WM_KEYDOWN messages. The CFrameWnd-derived mainframe is getting them but not passing them along: BOOL CMainFrame::OnCmdMsg(UINT nID,int nCode,void* pExtra,AFX_CMDHANDLERINFO* pHandlerInfo) { // let view have first crack at the command if(m_activeView->OnCmdMsg(nID,nCode,pExtra,pHandlerInfo)) return TRUE; // otherwise do default handling return CFrameWnd::OnCmdMsg(nID,nCode,pExtra,pHandlerInfo); } Shouldn't the above send off the message ? I was thinking of just calling SendMessa...

Problem with inbound E-mail via Road Runner
I have set-up my Outlook 2003 to send and receive E-mail from my broadband provider, Time Warner's Road Runner. I can send mail just fine, but when a message is sent to me, it does not come into my Outlook program. I have checked, double checked and triple checked the settings and everything tests out fine. Feedback? Thanks in advance for any assistance. DCD <DCD@discussions.microsoft.com> wrote: > I have set-up my Outlook 2003 to send and receive E-mail from my > broadband provider, Time Warner's Road Runner. I can send mail just > fine, but when a message ...

Dependents problem
Hi all, I have an input cell that is data validated. It is the only cell currently selected. In VBA immediate (or in a module) if I check for ?selection.dependents.count it tells me the (1004) No cells were found. yet when I enter selection.showdependents it shows the dependency "button" and arrow. If I look at selection in the watch window, Dependents - (No cells were found) Directdependents - (No cells were found) Please can anybody shed some light on this? Kind regards, Bony -- "There are 10 types of people in this world. Those who under...

Problem with subforms
Hello, I am developping an application with VBA & Access. I created a form containing 15 subforms controls (one above the other) , and I am trying to make the subforms controls look good and all equals. These controls are supposed to show each one a subform nammed SF_MYSUBFORM that I have designed. It has 10 fields from left to right. So I wish to have the form display the subforms controls looking as if they were the rows of an array. When I inserted the "subform controls" in the form, I used the control situated in the Access toolbar. But each "subform control" h...

having a problem installing MSCRM 1.2!
I am having a problem installing MSCRM 1.2. My configuration consists of a Domain Controller running Win 2000 Server SP4 . I am trying to install MSCRM on a member of the domain running Windows 2000 Server SP4. There is a DNS Server on the DC which is integrated with AD, and a SQL Server 2000 running on the Win 2K machine. The install errors out when CRM creates the root business with the message: Setup was unable to install Microsoft CRM Server. Setup was unable to provision your organization. Setup was unable to create the root business. The configuration of ASP.NET seems to be ok, the pr...