Solved

Function: substring in MSXML 3.0

Posted on 2003-11-26
1
517 Views
Last Modified: 2012-05-04
Hi,

I need an xpath query to extract nodes based on a given month and year.  The following code snippet works fine in MSXML4, but errors with unknown method in MSXML3.  I have checked the MS website and substring is supported in version 3 of MSXML.

Unfortunately, I must use MSXML3.  Can anyone assist?

Thanks
XML
<PageData>
 <Data>
  <Date>2003/11/06</Date>
  <Subject>Test</Subject>
  <Detail>uiouio</Detail>
 </Data>
</PageData>
XPath Query
xxx.SelectNodes("PageData[Data[Date[substring(.,1,7) =" & Chr(34) & Year(dtCurViewMonth) & "/" & Month(dtCurViewMonth) & Chr(34) & "]]]")
0
Comment
Question by:TopCat_UK
1 Comment
 
LVL 26

Accepted Solution

by:
rdcpro earned 250 total points
ID: 9826084
MSXML 3 defaults to the old XSL Patterns language, for backwards compatibility reasons.  You must specify XPath as the selection language after you instantiate the parser:


In JScript:

var xmlDoc = new ActiveXObject("Msxml2.DomDocument");
xmlDoc.setProperty("SelectionLanguage", "XPath");
// set other options here


Regards,
Mike Sharp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with SimpleXML charts with PHP 4 101
Strange html entity encoding by tidy 14 95
XML Removal- Powershell 4 29
TSQL XML Namespaces 7 24
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question