Categories

CODE
Visual C++ Programming
C++ (Non Visual C++ Issues)
Modern Windows Apps (Metro)
C++ and WinAPI
Managed C++ and C++/CLI
Visual C++ Bugs & Fixes
Graphics Programming
Multithreading
Network Programming
Driver Development
Visual Basic 6.0 Programming
Visual Basic .NET
Crystal Reports
C-Sharp Programming
Managed C++
Visual Basic .NET
ASP.NET
.NET Framework
ADO.NET
Windows Presentation Foundation (WPF) & XAML forum
Silverlight
.NET Installation and Configuration Issues
Java Programming
AJAX
Scripting - Client Side
Database
XML
Wireless/Mobile Development
Assembly
Scripting - Server Side (PHP, Perl, etc.)
Python
General Developer Topics
Project Planning, Design, and Management
Testers and Testing
Algorithms & Data Structures
General Discussion / Chit Chat
Announcements, Press Releases, & News
Feedback
Articles Suggestions
Testing Area
Programming Projects
C# Game(s) Project
Game Engine Project
C++ Coding Project
Project: Code War
Slow Chat: Talk with Microsoft Developer Teams
Slow Chat: Developing Multithreaded Applications
Slow Chat: C++0x
Slow Chat: Visual C++: Yesterday, Today, and Tomorrow
Directory Services
General Windows and DNA Programming
Windows OS Issues
Open Positions (Jobs)
Looking for Work
Visual Basic .NET FAQs
Visual Basic FAQs
CodeGuru Individual FAQs
CodeGuru Individual Visual Basic FAQs

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

XML

This is a catch-all for any XML related issues using XML, XDR, XSL/T, etc.

wildcards in attribute values


Hi there,  I'm having trouble trying to search nodes by attributes using wildcards in the values. e.g.:  <people>   <person>      <friend name="mister ex"/>      <friend name="miss ex"/>      <friend name="miss new"/>   </person> </people>  i want to select all nodes with values containing " ex". Does anyone know how I could get this? Would really help a lot!  Thanks in advance!     				  			

  				  					  	Code:  	<!-- I just wanted to try and post in the new system but I am pretty sure this will work -->    <xsl:value-of select="//friend[contains(@name,'ex')]"/>    <!-- this should find every friend node where the name attribute contains "ex" -->     				  			

  				  					Oh rats! The xpath syntax is correct:   	Code:  	"//friend[contains(@name,'ex')]"    for a query; however, it is useless in the context I put it in ("value-of").     Share and enjoy!  				  			

  				  					Thanks for the hint but in our particular problem it did not help.     We have a large xml file and must find names (attributes) containing a certain substring. Would be nice if msxml4 had something like that else we have to search the strings in the code which is much slower...    Any other Ideas??  				  			

  				  					Using msxml4 in vb the code would look something like this:      	Code:  	Dim xmlDoc As New MSXML2.DOMDocument  Dim xmlNodes As MSXML2.IXMLDOMNodeList    xmlDoc.LoadXML "<People><Person><Friend Name=""mister ex""/></Person></People>"    Set xmlNodes = xmlDoc.SelectNodes("//Friend[contains(@Name,'ex')]")     				  			

  				  					Seeing that you are searching for a substring, you might want to take a look at using SAX.  You can find information on MSDN.  It is an inline processor that is a little more efficient when doing inline searches...  				  			

  				  					Problem is I'm using the DOM Parser together with 3 other programmers involved in the project and either we find a solution with DOM or we would have to change about 10 applications. Not a nice thing to do...  And MSDN says you should use SAX when having memory problems, which we don't and that DOM is faster which is more important to us.  If DOM does not support this sort of search we will have to implement it ourselves.    Thx.  				  			

  				  					Is the problem still not solved then?  				  			

  				  					not the way we wished, that is with a DOM method.  we're now searching for all possible nodes and getting the right ones with string compare. It works but its not nice.    Unfortunately the code you posted doesn't work... Maybe it only works in VB and not in C++!       Bye  				  			

  				  					The language shouldn't matter (except the syntax would more likely be xmlDoc->SelectNodes("...");    This syntax does require a more current version of the msxml parser. v4 works, v3 might work, v2.x probably won't work.    pjp  				  			

  				  					Now I got it.    Man I must be stupid. I was trying it on the selectSingleNode function and there it seems not to work.   The function you were talking about, that is selectNodes(), there it works.    Thanks a lot PjPark for your help and patience!!!!  				  			

  				  					The smarter you are, the dumber the mistakes you make.      You're welcome.    pjp


Related Links

[XSL+VBscript] how to pass parameters to my function ?
Need some directions on first XML project
request (get or post) values
XML schema and nillable
XML beginner books
Counting Items
Free IDE for XML
XML Weather Service
How to get substring using in an XSL
Problem with TransformNodeToObject
File Upload using WEBDAV
&lt;![cdata
Web Services Security SSL encryption
Calling external modules from XML
Use of regular expression in Xpath
Download page as XMl