By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Is this a problem with / or . within the data values?

P: n/a
JB
Does anyone know why this code works in example A but not in example B ? Is
this a problem with special characters within the data values?

A) Set xmlNodeList =
xmlParentNode.selectNodes("//PredecessorLink[CrossProjectName='A5']")
B) Set xmlNodeList =
xmlParentNode.selectNodes("//PredecessorLink[CrossProjectName='\\winntpath\mypath\file.mpp\1']")

The data contains both values, but the code can't find the
'\\winntpath\mypath\file.mpp' value...
<PredecessorLink>
<CrossProject>1</CrossProject>
<CrossProjectName>A5</CrossProjectName>
</PredecessorLink>
<PredecessorLink>
<CrossProject>1</CrossProject>
<CrossProjectName>\\winntpath\mypath\file.mpp\1</CrossProjectName>
</PredecessorLink>


Mar 5 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JB wrote:
B) Set xmlNodeList =
xmlParentNode.selectNodes("//PredecessorLink[CrossProjectName='\\winntpath\mypath\file.mpp\1']")

The data contains both values, but the code can't find the
'\\winntpath\mypath\file.mpp' value...
<PredecessorLink>
<CrossProject>1</CrossProject>
<CrossProjectName>A5</CrossProjectName>
</PredecessorLink>
<PredecessorLink>
<CrossProject>1</CrossProject>
<CrossProjectName>\\winntpath\mypath\file.mpp\1</CrossProjectName>
</PredecessorLink>
Works for me with MSXML 3 if setProperty "SelectionLanguage", "XPath" is
called before the selectNodes call:

Dim XmlDocument, XmlNodeList
Set XmlDocument = CreateObject("Msxml2.DOMDocument.3.0")
If XmlDocument.load("test2007030601.xml") Then
XmlDocument.setProperty "SelectionLanguage", "XPath"
Set XmlNodeList =
XmlDocument.selectNodes("//PredecessorLink[CrossProjectName='\\winntpath\mypath\file.mpp\1']")
WScript.Echo "Found " & XmlNodeList.length & " element(s)."
Else
WScript.Echo xmlDocument.parseError.reason
End If

If you use MSXML 3 and selectSingleNode/selectNodes make sure you call e.g.
XmlDocument.setProperty "SelectionLanguage", "XPath"
once before making any selectSingleNode/selectNodes calls with XPath
expressions.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.