XPath-syntax: referencing node with " in attribute-value

Hello NG!

Within attribute-values i can use the double quote, which is written 
automaticly
 as """ into the document by the XML-methods of .NET:
<Node Name="a&quot;b" Att1="true"/>

But how to reference such nodes with an XPath-expression?
=> pXml.SelectSingleNode("//Folder[@Name=??]")

What's the correct Syntax?

Thanks for any help!
Regards, D.Barisch



0
Daniel
10/26/2007 1:48:37 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
536 Views

Similar Articles

[PageSpeed] 43

Daniel Barisch wrote:

> Within attribute-values i can use the double quote, which is written 
> automaticly
> as "&quot;" into the document by the XML-methods of .NET:
> <Node Name="a&quot;b" Att1="true"/>
> 
> But how to reference such nodes with an XPath-expression?
> => pXml.SelectSingleNode("//Folder[@Name=??]")
> 
> What's the correct Syntax?

With C# you can use
   pXml.SelectSingleNode("//Node[@Name = 'a\"b']")
With VB.NET you can use
   pXml.SelectSingleNode("//Node[@Name = '\""b']")

The real problem only occurs if the attribute value contains single 
_and_ double quotes. In that case you would need to break up the string 
into components.
-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
10/26/2007 1:28:51 PM
Martin Honnen wrote:
> Daniel Barisch wrote:
> 
>> Within attribute-values i can use the double quote, which is written 
>> automaticly
>> as "&quot;" into the document by the XML-methods of .NET:
>> <Node Name="a&quot;b" Att1="true"/>
>>
>> But how to reference such nodes with an XPath-expression?
>> => pXml.SelectSingleNode("//Folder[@Name=??]")
>>
>> What's the correct Syntax?
> 
> With C# you can use
>   pXml.SelectSingleNode("//Node[@Name = 'a\"b']")
> With VB.NET you can use
>   pXml.SelectSingleNode("//Node[@Name = '\""b']")
> 
> The real problem only occurs if the attribute value contains single 
> _and_ double quotes. In that case you would need to break up the string 
> into components.

And even for that problem there is a solution, such as using variables. 
Here is a sample - http://www.tkachenko.com/blog/archives/000385.html

-- 
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net
0
some2113 (163)
10/28/2007 10:02:55 AM
Reply:

Similar Artilces:

"Are you sure" prompt in Outlook
I have a strange request from my HR Dept. they want to split our All EMployee dist. list in to 4 groups and lock them down to a specific range of users who can send to them, this is no problem. The problem comes in with them also wanting to know if we can set anything up that, when these groups are sent to, a message is presented with soemthing like, "Are you sure you want to send this to everyone", etc. I told them that there is no way to do this without 3rd party software or heavy customization, but I wanted to check with the groups to see if anyone has accomplished thi s...

where can I find details about "AfxGetThreadState()" ?
Hi, folks There are many usage with AfxGetThreadState(...) function, but I dont know how and where use it. So, please give some details or webaddress about it. :-p Thnx :-) Frank "Frank Han" <winsays@hotmail.com> wrote in message news:%23U3yn%23vhDHA.1952@TK2MSFTNGP10.phx.gbl... > Hi, folks > > There are many usage with AfxGetThreadState(...) function, but I dont know > how and where use it. > So, please give some details or webaddress about it. :-p It's an MFC internal function. The documentation is the MFC source code. Cheers Richard. See the fol...

OWA Setting "Out of Office Assistant" don't work. --"
Dear sir I have setting Out of Office Assistant in OWA. on my e-mail address. and testing sending e-mail to my e-mail, it is't autoreply to sendor. How i do for resolve this problemd. --" Exchange 2003 server Pls help me -- Message posted via http://www.winserverkb.com Out of Office Assistant by default only work for internal mail, not for internet mail, if you want to use Out of Office Assistant for emails send from internet you need too turn it on under Global Settings -> Internet Message Format but is not recomended. Nebojsa Seslija "Kangyut Champasit via Win...

VLOOKUP syntax
I am trying to use a VLOOKUP function within a macro. The code I am currently attempting to use is: VLOOKUP(RC3,'LMon & " CF"'!R8C3:R260C27,'LMon & " CF"'!R[4] C[11],0) where LMon is a defined variable that holds name of the previous month. For example "Dec CF" is one of the sheets in my workbook. With the syntax above I am getting a Compile Error. Can someone tell me how this shuld be correctly written. TIA, JC "JC" <jcarlsen@ti.com> wrote in news:0de601c3daac$023e8e30 $a101280a@phx.gbl: > VLOOKUP(RC3,'...

XPath
Using XPath I am querying parts of XML document, " get quoted by \ - is it possible to specify not to quote " with \? <RootElement> <Element Attribute="SomeValue" /> </RootElement> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); XmlNode xmlNode = xmlDoc.SelectSingleNode("//RootElement/Element") Print xmlNode.OuterXml <Element Attribute=\"SomeValue\"/> where I was expecting to get <Element Attribute="SomeValue"/> TIA Dennis wrote: > Using XPath I am querying parts of XML document,...

What does it mean "You need to reinstall metamail?" And how?
I got a pop-up that said "we have detected a new version of Outlook on your machine. You need to reintsall metamail." But no other details. This is when I was first setting up Outlook on a new computer. I have Ofc Prof 2003, and it asked for my email info, and I told it my address was "chorrace@yahoo.com" and it asked for the URL and I said Yahoo.com. Was that right? This is my first time using Outlook as a stand-alone. Before I was in a network. Do you have an addin called Metamail installed? Unless you pay for pop3 support with Yahoo, you can't use Outl...

Creation of "Resources"
We recently moved from Groupwise to Exchange and we're very pleased with the change. I'm wondering...is there a way to create a "resource" like in Groupwise? Say, we have a meeting room or digital projector that could be scheduled...I'd like to be able to show that as a resource within the Exchange system so that everyone could see it and schedule it as necessary. Thanx. There isn't a separate designation of resource, per se. Instead, what you would do is create a new user account/mailbox (you can then disable the user account as long as you re-insert the SE...

How do I input figures into the "Actual Column" when I create a bu
I'm creating a new budget and I filled in all the Planned column figures. How do I fill in the Actual column? It's supposed to figure it out from categorized transactions in account registers for the time periods in question. "llckll" <llckll@discussions.microsoft.com> wrote in message news:42ED1979-A0F5-4D49-9478-499532113833@microsoft.com... > I'm creating a new budget and I filled in all the Planned column figures. > How do I fill in the Actual column? That's what I figured. Thanks! Another question, how would I and should I categorize trans...

Problem: the "color fill" in Excel is NOT showing up on the screen
SWhen I click the "color fill" button to highlight a cell in Exel the color is not showing up on the screen, however it shows up as colored in the Print Preview, or if I print. something has been turned off by someone else and I do not know how to reset it so that I can see the cells that I highlight. I have Windows XP. If the high contrast setting is turned on you won't see the fill colour. There's information in the following MSKB article: OFF: Changes to Fill Colour and Fill Pattern Are Not Displayed http://support.microsoft.com/?id=320531 UC2Pyrs wrote:...

What does the "--" do?
First off, I wasn't sure where to post this because I didn't know if th -- is classified as a worksheet function or not, but what does it do? I've seen them in a bunch of posts. I am just curious what they do. Example: =SUMPRODUCT(--($D$1:$D$100="100"),$F$1:$F$100) versus =SUMPRODUCT(($D$1:$D$100="100"),$F$1:$F$100) Why does the second one not work? Thanks, Nic -- thekovin ----------------------------------------------------------------------- thekovinc's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2937 View this thread:...

Getting a specific parent of any node via xpath navigation
I am storing my site structure as such: <menuItems> <menuItem> <pageID>1</pageID> </menuItem> <menuItem> <pageID>2</pageID> <menuItem> <pageID>4</pageID> <menuItem> <pageID>5</pageID> <menuItem> <pageID>6</pageID> </menuItem> </menuItem> </menuItem> </menuItem> <menuItem> <pageID>3</pageID> ...

New Update causes " Communication Error"
I have tried several times to install this new update and still get the same error message. The message is "A communication error occured. Please try your call again. If you continue to have problems call your financial institution's Online Services Customer Support." I thought this update was suppose to fix issues between MS Money and MSN Money in which there was hugh problems. Now, I am forced to re-install MS Money Premium without this update until it is fixed. Fortunately, I backup my files on multiple disks. System Information: XP Professional SP2, Internet Explo...

XML Nodes conversion to Hashtable
Hi m not able to convert the node values of a XML file to Hashtable Actaully i need to traverse the XML Nodes again and again and want to pick values on filters what i want is to stroe the XML values in the Hashtable and return then from Hashtable (the hashtable will be filled only once) this will optimise the performance because the XML is not updated (or updated rarely) Thanks in advance On Sat, 25 Nov 2006 04:59:01 -0800, Manish wrote: > Hi m not able to convert the node values of a XML file to Hashtable > > Actaully i need to traverse the XML Nodes again and again and ...

help with inserting a cell value into a named formula
If someone could help me solve this conundrum, I'd be wonderfully grateful... The Setup - I've got 2 columns, one named "text", one named "numbers"; lets say A,B,C,& D in A1-A4, and 1,2,3,&4 in B1-B4. I also have four formulas - let's say they're named AA,BB,CC,&DD. (AA would multiply by 2, BB multiply by 3, CC by 4, DD by 5). The Problem - In column C, I want to have an IF function that... logical_test = looks at whether the value of a cell in a "text" column cell is A,B,C,orD, value_if_true = uses the corresponding formula (AA,...

Help with syntax error
Could someone help me debug this in Access 2003? I have been staring at it all afternoon and I can't seem to get it: strQuery = "UPDATE CMMonth " & _ "SET Countermeasure = '" & Countermeasure & "'" _ " WHERE PartNo = '" & HoldPartNo & "'" _ " AND WeekNo =" & HoldWeekNo & _ " AND CMYear =" & HoldCMYear & _ " AND CarryOver = -1&...

Drawing Layer Objects "Dropping Out"
Sorry if this is a common question, I scanned through 18 pages of this newsgroup and didn't see anything that related to my question. Anyway, on to the question... I have a chart (obviously) that plots information for a team meeting. The presentation is fairly complex, the data is plotted on both axis, and there are several chart types supported on the chart. My problem is that we also do an automated assessment of the information and want the color coded "dashboard" to appear on the graph in the drawing layer. The dashboard is comprised of several named text objects ...

"Interface not registered" and "OLE registration error"
When I try to send email from Outlook 2003 using Word 2003 as my HTML email editor, I get an "Interface not registered" error message. Also, when I try to reply to email where Word 2003 is the editor, I get the following error message: "Microsoft Word is set to be your e-mail editor. However, Word is not available, not installed, or is not the same version as Outlook. The Outlook e-mail editor will be used instead. An OLE registration error occurred. The program is not correctly installed. Run Setup again for the program." I notice that the versions are slightly d...

"too many records have been selected" warning in MCRM
I get the following informational message in MCRM when I select more than ten accounts to include as part of a report: "Too many records have been selected" I need to be able to generate report for more than ten accounts at a time and need to be able to change this restrictive setting. Can this be changed and if so, where do I change it? Thanks Hello Mark I do not have my report dev tools to hand but I would think that there is some code in the report that is saying dont report if more than 10 records are selected. You should download the report to an RDL file and edit i...

XPath pb
Hi In infopath, I use a XPath expression to get some nodes : var oEMailNodeList = XDocument.DOM.selectNodes("//Message/EMail"); My problem is that this method returns 0 items. Here is the DOM.xml property : <?xml version="1.0" ?> <?mso-infoPathSolution productVersion=\"11.0.5329\" PIVersion=\"1.0.0.0\" href=\"file:///C:\Documents%20and%20Settings\t-stevbe\Local%20Settings\Appli cation%20Data\Microsoft\InfoPath\7ab6e8af39fc42e2\manifest.xsf\" solutionVersion=\"1.0.0.9\" initialView=\"messagesList\" ?> <?...

Summing data referencing incremental cells
Novice Excel 03 user. I have daily production totals in row 6 starting in column C and going across. In row 83 I would like to start a weekly sum of the data from row 6. What can I do so that when I sum C6:C10 in C83 I can copy it to D83 and sum C11:C15? I believe that I need to reference the number of cells to be summed, but what about short weeks? Is there anything that can recognize sequential dates above the daily totals so that it knows to stop the sum if the work week is a 3 or 4 day week? Any help would be greatly appreciated. -- Mike Where can we read the date appropriat...

SCHTask.exe returns "Failed to start" from SVR 2008
Hi, We have a number of 2003 servers which run lots of scheduled tasks around the clock. We also have some 2008 servers which do the same. We use SCHTask.exe from the 2008 servers, to query the scheduled tasks on the 2003 servers, and then look through the output of this query for errors, which is then used elsewhere to alert us that a scheduled task has failed on a given machine, and what the task is called. The problem we are having is that if a scheduled task runs sucessfully on a 2003 server, but has a NON ZERO return code, when SCHTask is run from a 2008 server and quer...

How to pass a Nodeset to an XPath extension function?
I am using the .NET framework v2.0.40607 with Visual C# Express and I would like to create some custom XPath functions to use directly in a XSLT stylesheet. I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object) to register the functions I've written. The functions that take a String, Boolean or Number parameter work perfectly. However, I do not know how to create a function that will accept a Nodeset as a parameter. I tried writting a function taking a XPathNavigator object, but it does not work for all XPath queries that return a Nodeset: I get an error &qu...

"Look for" option not available
For some reason, when I start outlook 2002 and select contacts, the "Look for" option is not available and outlook is accessing the internet instead. Very strange. This is happening since I installed a "Free" pupup blocker. I have since uninstalled it but I still have the outlook problem. ...

Remove/delete "Newsgroups"
While attempting to download a "few" Exchange related newsgroups to my Exchange 2000 Server, I somehow managed to get a few thousand entries in the "Newsgroups" container under SERVER >NNTP >Default NNTP Virtual Server. This was not the desired effect. I've found and included information below from a previous post, but the solution is not correct. The suggested solution is to remove the "Feed", which I have done, but that does not remove all of the entries in the "Newsgoups" container. How can I delete all those entries without selecting and ...

Where can I find the file ABC Sales.xls used in the Book "Running.
I have just purchased "Running Microsoft Excel2000". It gives me an address to where I can get the files used in the examples, I just can't find them. The address given is http://mspress.microsoft.com/mspress/products/2050. I would appreciate any help you can give me. camper56 wrote: || I have just purchased "Running Microsoft Excel2000". It gives me an || address to where I can get the files used in the examples, I just || can't find them. The address given is || http://mspress.microsoft.com/mspress/products/2050. I would || appreciate any help you can give me....