Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 5th, 2007, 09:55 PM
JB
Guest
 
Posts: n/a
Default Is this a problem with / or . within the data values?

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>




  #2  
Old March 6th, 2007, 12:45 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Is this a problem with / or . within the data values?

JB wrote:
Quote:
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/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles