Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Selecting multiple nodes using the selectNodes method.

Hi all

I need to select all <input> and <select> nodes using XML.selectNodes

I can retrieve a nodelist set using
oXML.selectNodes("//input")

How do I specify "and //select" to include all the <select> elements in the nodelist?

S
0
Skin
Asked:
Skin
1 Solution
 
dragoshCommented:
try this :

selectNodes("//(input|select)")
0
 
rdovCommented:
Since the expression can use either the XPath 1.0 or XSL Patterns syntax, there needs to be a way to specify the selection language before using these APIs. To maintain backwards compatibility with existing code, the default selection language is XSL Patterns. To change the current selection language to XPath, call the new setProperty method (see IXMLDOMDocument2) using the SelectionLanguage property name and the value XPath:
node.ownerDocument.setProperty "SelectionLanguage", "XPath"
applyExpression node, "/child::foo/descendant::bar/baz"
To set the selection language back to XSL Patterns, simply call setProperty again using the value XSLPattern.

for more information:
http://msdn.microsoft.com/library/periodic/period00/xml0900.htm 

HowTo: Use XPath Queries in MSXML DOM selectNodes Method:
http://support.microsoft.com/support/kb/articles/Q288/9/13.ASP

Extensible Stylesheet Language (XSL):
http://www.w3.org/TR/1998/WD-xsl-19981216.html

try also this link:
http://msdn.microsoft.com/xml/samples/index.asp
(for example:
http://msdn.microsoft.com/xml/samples/authors/author-patterns.htm)

0
 
MoondancerCommented:
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.
____________________________________________
---------->  Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

------------->  The ALL TOPICS link has been updated today to reflect all the new TAs.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
b1xml2Commented:
answer is:

applicable only to MSXML3+

JScript
========
oXML.setProperty("SelectionLanguage","XPath");
var oNodeList = oXML.selectNodes("//*[self::input or self::select]");


VBScript
==================
Dim oNodeList
oXML.setProperty "SelectionLanguage","XPath"
Set oNodeList = oXML.selectNodes("//*[self::input or self::select]")

VB
===
Dim oNodeList As IXMLDOMNodelist
oXML.setProperty "SelectionLanguage","XPath"
Set oNodeList = oXML.selectNodes("//*[self::input or self::select]")
0
 
b1xml2Commented:
<review>

<special>
Answer provided to add value to PAQ.
</special>

<recommendation>
split between rdov and b1xml2
</recommendation>

<objection>
any objection should be raised within 7 days
</objection>

<reviewer>
b1xml2
</reviewer>

</review>
0
 
NetminderCommented:
Per recommendation, force-accepted by
Netminder
CS Moderator

b1xml2: points for you at http://www.experts-exchange.com/jsp/qShow.jsp?ta=xml&qid=20290641
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now