Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
SQL
ce
clients
clustering
connect
datamining
datawarehouse
dts
fulltext
jdbcdriver
msde
mseq
newusers
notificationsvcs
odbc
olap
programming
replication
reportingsvcs
security
securitytools
server
setup
sqlxml.viewmapper
tools
xml
  
 
date: 21 Feb 2007 06:25:48 -0800,    group: microsoft.public.sqlserver.reportingsvcs        back       


unable to parse RDLC with xpath   
First, I add a new report in Visual Studio 2005 (SP1) to get an empty
RDLC file.

Then, i try to get a reference to a node in this xml file using either
SelectSingleNode in System.Xml namespace or the more advance
SelectSingleNode-function in the System.Xml.Path namespace. But the
function returns null because it does not find a match.

If have tried to use a XMLNameSpaceManager without success.

However, when i remove the default namespace from the rdl-definition
the call succeeds!


            string filename = @"C:\demo\aa.xml"; // this is an report
file...

            XmlDocument document = new XmlDocument();
            document.Load(filename);

            XPathNavigator nav = document.CreateNavigator();
            nav = nav.SelectSingleNode("//Report/Body/ReportItems/
Rectangle[@Name='rctPage3']/ReportItems");


SelectSingleNode("//") works but not SelectSingleNode("//Report") for
example.

I have two files that look identical in notepad, but differ somewhere
in binary, they are utf8-encoded (allthough report files are ansi-
encoded as of default??) aa.xml and bb.xml.

One is working but not the other...???

All help is appreciated.
/Victor Cassel
date: 21 Feb 2007 06:25:48 -0800   author:   unknown

Re: unable to parse RDLC with xpath   
On 21 Feb, 15:25, victor.cas...@gmail.com wrote:
> First, I add a new report in Visual Studio 2005 (SP1) to get an empty
> RDLC file.
>
> Then, i try to get a reference to a node in this xml file using either
> SelectSingleNode in System.Xml namespace or the more advance
> SelectSingleNode-function in the System.Xml.Path namespace. But the
> function returns null because it does not find a match.
>
> If have tried to use a XMLNameSpaceManager without success.
>
> However, when i remove the default namespace from the rdl-definition
> the call succeeds!
>
>             string filename = @"C:\demo\aa.xml"; // this is an report
> file...
>
>             XmlDocument document = new XmlDocument();
>             document.Load(filename);
>
>             XPathNavigator nav = document.CreateNavigator();
>             nav = nav.SelectSingleNode("//Report/Body/ReportItems/
> Rectangle[@Name='rctPage3']/ReportItems");
>
> SelectSingleNode("//") works but not SelectSingleNode("//Report") for
> example.
>
> I have two files that look identical in notepad, but differ somewhere
> in binary, they are utf8-encoded (allthough report files are ansi-
> encoded as of default??) aa.xml and bb.xml.
>
> One is working but not the other...???
>
> All help is appreciated.
> /Victor Cassel

Here is a shorter stating of the problem.

Can anyone show me a code example (vs 2005) of how to parse the
simplest possible RDLC with an xpath query with SelectSingleNode?

There seems to be some problem with the namespaces in the RDLC-files.

//victor
date: 22 Feb 2007 05:21:13 -0800   author:   unknown

Re: unable to parse RDLC with xpath   
On 22 Feb, 14:21, victor.cas...@gmail.com wrote:
> On 21 Feb, 15:25,victor.cas...@gmail.com wrote:
>
>
>
>
>
> > First, I add a new report in Visual Studio 2005 (SP1) to get an empty
> > RDLC file.
>
> > Then, i try to get a reference to a node in this xml file using either
> > SelectSingleNode in System.Xml namespace or the more advance
> > SelectSingleNode-function in the System.Xml.Path namespace. But the
> > function returns null because it does not find a match.
>
> > If have tried to use a XMLNameSpaceManager without success.
>
> > However, when i remove the default namespace from the rdl-definition
> > the call succeeds!
>
> >             string filename = @"C:\demo\aa.xml"; // this is an report
> > file...
>
> >             XmlDocument document = new XmlDocument();
> >             document.Load(filename);
>
> >             XPathNavigator nav = document.CreateNavigator();
> >             nav = nav.SelectSingleNode("//Report/Body/ReportItems/
> > Rectangle[@Name='rctPage3']/ReportItems");
>
> > SelectSingleNode("//") works but not SelectSingleNode("//Report") for
> > example.
>
> > I have two files that look identical in notepad, but differ somewhere
> > in binary, they are utf8-encoded (allthough report files are ansi-
> > encoded as of default??) aa.xml and bb.xml.
>
> > One is working but not the other...???
>
> > All help is appreciated.
> > /VictorCassel
>
> Here is a shorter stating of the problem.
>
> Can anyone show me a code example (vs 2005) of how to parse the
> simplest possible RDLC with an xpath query with SelectSingleNode?
>
> There seems to be some problem with the namespaces in the RDLC-files.
>
> //victor- Dölj citerad text -
>
> - Visa citerad text -

I found the answer myself.

Apparently, the default namespace does not work with the namespace
manager, so you have to give the default name space a name, for
example ns.

Then your xpath questions work, if you write them like this:

        XmlNamespaceManager ns = new
XmlNamespaceManager(pg1.NameTable);
        ns.AddNamespace("ns", "http://schemas.microsoft.com/sqlserver/
reporting/2005/01/reportdefinition");
        ns.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/
reporting/reportdesigner");

        string source = "//ns:Report/ns:Body/ns:ReportItems/
ns:Rectangle[@Name='rctPage']/ns:ReportItems";

        MessageBox.Show(pg1.SelectSingleNode(source, ns).InnerXml);

Notice that you should not add the namespace identifier for
attributes, see @Name above.  Very strange, but it works.

/Victor
date: 1 Mar 2007 03:46:23 -0800   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us