views:

69

answers:

2

Hi i have a document from which i am trying to extract a date. But the problem is within the node along with the date their is some text too. Something like

 <div class="postHeader">  
 Posted on   
   July 20, 2009  9:22 PM PDT  

   </div>  

From this tag i just want the date item not the Posted on text. something like
./xhtml:div[@class = 'postHeader'] is getting everything. and to be precise, the document i have is basically a nodelist of this elements for eg i will get 10 nodes of these elements with different date values but to be worse the problem is sometime inside these tags some random other tags also pops us like anchors etc. Can i write a universal expath which will just get the date out of the div tag?

A: 

yup, but minutely. They might have an additional <a> tag or a <br> but thats it, All postHeader has a date for sure

NA
You should have either posted this as a comment or edit your question to include this information, not as an answer to your own question.
Oded
A: 

With XSLT 2.0 you have the xpath function matches() and replace(). Do you have XPATH 2.0 available?

Patrick
@Patrick - this is not an answer, so it should have been a comment on the question.
Oded
@Oded, I'd slightly disagree. I have mentioned the two xpath functions that do the trick.
Patrick
@Patrick - And if he is on version 1.0, how is this an answer? Ask as a comment, get an answer and only then post an answer.
Oded
@Oded: SO is also for future reference, so if someone in the future comes across this question and has XSLT 2.0 available, then he can see my answer, even if the original poster doesn't have 2.0.
Patrick