Xpath Help! 
Author Message
 Xpath Help!

Hi all I am trying to extract value of a given id out of an Xml Doc
depending on an XSLT expression. In normal fashion I call the expression get
an iterator back and then basically through the iterator get the value.
Can I not get the value as Evaluate?

Thanks

   XPathNavigator nav=doc.CreateNavigator();

   StringBuilder sbExpr= new StringBuilder();

   sbExpr.AppendFormat("value-of select=\"

   string val=(string)nav.Evaluate(sbExpr.ToString()); //fails

    // This works fine!!!

   //XPathNodeIterator iterator = nav.Select(expr);
   //while (iterator.MoveNext())
   //{
    //strtemp=iterator.Current.Value;
   // }

--
*************
Best Regards
Satch
*************



Mon, 13 Dec 2004 23:00:22 GMT  
 Xpath Help!
Satch,

    I don't quite understand.  it should fail because you aren't giving it a
valid XPath expression, you are giving it an attribute defined in XSLT and
the XPath expression.  It works when you use JUST the XPath expression, as
it should.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Hi all I am trying to extract value of a given id out of an Xml Doc
> depending on an XSLT expression. In normal fashion I call the expression
get
> an iterator back and then basically through the iterator get the value.
> Can I not get the value as Evaluate?

> Thanks

>    XPathNavigator nav=doc.CreateNavigator();

>    StringBuilder sbExpr= new StringBuilder();

>    sbExpr.AppendFormat("value-of select=\"

>    string val=(string)nav.Evaluate(sbExpr.ToString()); //fails

>     // This works fine!!!

>    //XPathNodeIterator iterator = nav.Select(expr);
>    //while (iterator.MoveNext())
>    //{
>     //strtemp=iterator.Current.Value;
>    // }

> --
> *************
> Best Regards
> Satch
> *************



Mon, 13 Dec 2004 23:02:35 GMT  
 Xpath Help!
what's the solution. U get what I am trying to achieve? I am trying to
eliminate the iterator step since ther is just 1 value

Thanks


Quote:
> Satch,

>     I don't quite understand.  it should fail because you aren't giving it
a
> valid XPath expression, you are giving it an attribute defined in XSLT and
> the XPath expression.  It works when you use JUST the XPath expression, as
> it should.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > Hi all I am trying to extract value of a given id out of an Xml Doc
> > depending on an XSLT expression. In normal fashion I call the expression
> get
> > an iterator back and then basically through the iterator get the value.
> > Can I not get the value as Evaluate?

> > Thanks

> >    XPathNavigator nav=doc.CreateNavigator();

> >    StringBuilder sbExpr= new StringBuilder();

> >    sbExpr.AppendFormat("value-of select=\"

> >    string val=(string)nav.Evaluate(sbExpr.ToString()); //fails

> >     // This works fine!!!

> >    //XPathNodeIterator iterator = nav.Select(expr);
> >    //while (iterator.MoveNext())
> >    //{
> >     //strtemp=iterator.Current.Value;
> >    // }

> > --
> > *************
> > Best Regards
> > Satch
> > *************



Mon, 13 Dec 2004 23:11:02 GMT  
 Xpath Help!
Satch,

    What are you getting back when you call Evaluate instead of select using
the same path (without the "value-of")?

--
               - Nicholas Paldino [.NET MVP]


Quote:
> what's the solution. U get what I am trying to achieve? I am trying to
> eliminate the iterator step since ther is just 1 value

> Thanks

wrote

> > Satch,

> >     I don't quite understand.  it should fail because you aren't giving
it
> a
> > valid XPath expression, you are giving it an attribute defined in XSLT
and
> > the XPath expression.  It works when you use JUST the XPath expression,
as
> > it should.

> >     Hope this helps.

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > Hi all I am trying to extract value of a given id out of an Xml Doc
> > > depending on an XSLT expression. In normal fashion I call the
expression
> > get
> > > an iterator back and then basically through the iterator get the
value.
> > > Can I not get the value as Evaluate?

> > > Thanks

> > >    XPathNavigator nav=doc.CreateNavigator();

> > >    StringBuilder sbExpr= new StringBuilder();

> > >    sbExpr.AppendFormat("value-of select=\"

> > >    string val=(string)nav.Evaluate(sbExpr.ToString()); //fails

> > >     // This works fine!!!

",1);
> > >    //XPathNodeIterator iterator = nav.Select(expr);
> > >    //while (iterator.MoveNext())
> > >    //{
> > >     //strtemp=iterator.Current.Value;
> > >    // }

> > > --
> > > *************
> > > Best Regards
> > > Satch
> > > *************



Mon, 13 Dec 2004 23:17:20 GMT  
 Xpath Help!
Crashes ther!!! stack trace doesn't has any info either!!
Thanks


Quote:
> Satch,

>     What are you getting back when you call Evaluate instead of select
using
> the same path (without the "value-of")?

> --
>                - Nicholas Paldino [.NET MVP]



> > what's the solution. U get what I am trying to achieve? I am trying to
> > eliminate the iterator step since ther is just 1 value

> > Thanks

> wrote

> > > Satch,

> > >     I don't quite understand.  it should fail because you aren't
giving
> it
> > a
> > > valid XPath expression, you are giving it an attribute defined in XSLT
> and
> > > the XPath expression.  It works when you use JUST the XPath
expression,
> as
> > > it should.

> > >     Hope this helps.

> > > --
> > >                - Nicholas Paldino [.NET MVP]



> > > > Hi all I am trying to extract value of a given id out of an Xml Doc
> > > > depending on an XSLT expression. In normal fashion I call the
> expression
> > > get
> > > > an iterator back and then basically through the iterator get the
> value.
> > > > Can I not get the value as Evaluate?

> > > > Thanks

> > > >    XPathNavigator nav=doc.CreateNavigator();

> > > >    StringBuilder sbExpr= new StringBuilder();

> > > >    sbExpr.AppendFormat("value-of select=\"

> > > >    string val=(string)nav.Evaluate(sbExpr.ToString()); //fails

> > > >     // This works fine!!!

> ",1);
> > > >    //XPathNodeIterator iterator = nav.Select(expr);
> > > >    //while (iterator.MoveNext())
> > > >    //{
> > > >     //strtemp=iterator.Current.Value;
> > > >    // }

> > > > --
> > > > *************
> > > > Best Regards
> > > > Satch
> > > > *************



Mon, 13 Dec 2004 23:33:13 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how to make multiple node queries on xml document using Xpath

2. How to read/write xml document using xpath?

3. XML namespace in XPath

4. trouble with Xpath navig

5. Navigation (xpath?) within an XmlDocument

6. Writing result of XPath query to disc

7. MSXML, DOM, and XPath filters

8. MSXML3 namespace prefix XPATH selectSingleNode

9. problem with xpath query -> .Net XMLDataDocument class

10. System.Xml.XPath

11. Sql "Distinct" in XPath

12. HELP HELP HELP HELP HELP HELP!!!

 

 
Powered by phpBB® Forum Software