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
Network Programming
Driver Development
Visual Basic 6.0 Programming
Visual Basic .NET
Crystal Reports
C-Sharp Programming
Managed C++
Visual Basic .NET
.NET Framework
Windows Presentation Foundation (WPF) & XAML forum
.NET Installation and Configuration Issues
Java Programming
Scripting - Client Side
Wireless/Mobile Development
Scripting - Server Side (PHP, Perl, etc.)
General Developer Topics
Project Planning, Design, and Management
Testers and Testing
Algorithms & Data Structures
General Discussion / Chit Chat
Announcements, Press Releases, & News
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


Java Database
Software Development
Software Development



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

Encrypt and Decrypt XML Code
XSLTransform fails with xmlns in DocumentElement
Problems creating xsd with restrictions
XmlSchema compilation problem (.NET Framework 1.1)
Pass info from page to page
how to parse xsd file in xerces?
Using XML Schemas in C++ Unmanaged Code
How to use html tags, inside CDATA
query question for VB6
xerces c++ memory leak? Or what is wrong in this code?
Tables with XSL
hey why dont this work :(
Easy xml/xsl question (not easy for me though...)
An XML application server problem
How to rename an xml node using xsl??