0
<?xml version="1.0"?>
<AppXmlLogWritter>
  <LogData>
    <LogID>5678201301161640382919</LogID>
    <LogDateTime>20130114164038</LogDateTime>            
  </LogData>
  <LogData>
    <LogID>5678201301161640382920</LogID>
    <LogDateTime>20130115154040</LogDateTime>           
  </LogData>
  <LogData>
  <LogID>5678201301161640382921</LogID>
  <LogDateTime>20130116164042</LogDateTime>          
  </LogData>
</AppXmlLogWritter>

strXpathQuery = @"/AppXmlLogWritter/LogData[LogDateTime/text()>=[starts-with(. , '20130115') and LogDateTime/text()<=starts-with(. , '20130116')]";

I have to write xpath query to select logdata in range where LogDateTime starts with 20130115 to 20130117 I am trying above query but fails to get data

1 Answer 1

1

Please give this a try:

/AppXmlLogWritter/LogData[substring(LogDateTime, 1, 8) >= 20130115 
                              and substring(LogDateTime, 1, 8) <= 20130116]

If you want to include 20130117 items in the selection, you would change the "20130116" value to "20130117".

Sign up to request clarification or add additional context in comments.

3 Comments

JL above query gives me zero nodes
Do you get any nodes if you just try /AppXmlLogWritter/LogData[LogDateTime]? Is the double "t" in "Writter" intentional?
It locates 2 nodes when I use it an XSLT. Could you post above the actual code you're using to run these XPath queries, with my suggested query included? What are you plugging the XPath into?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.