SolvedPrivate

Handle Ampersand in XML Linq

Posted on 2014-04-23
7
29 Views
Last Modified: 2016-02-15
I am trying to do a LINQ query and have a field that has an Ampersand rendered as &
<StateSpecialty stateKey="Alabama" specialtyKey="L&D" stateName="Alabama" state="AL" specialty="L&D" specialtyMarketing="Labor & Delivery">

For the life of me I cannot get the query to work

Below...I've passed in for _specialty
L&D
L%26D
And..the actual string    L&D
Nothing seems to work

            Dim regionElements = From r In doc.Descendants("StateSpecialty") _
                                 Where r.Attribute("state").Value = _state _
                                 And r.Attribute("specialty").Value = _specialty
                                 Select r

Open in new window

0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40018489
So filling _specialty with "L&D" doesn't work?
0
 

Author Comment

by:lrbrister
ID: 40018513
I get the red underline and this message on mouse over

specialty="L&D"

"Entity D is not defined
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40018566
Huh? In VB?

In other words, if you do this:

Dim regionElements = From r In doc.Descendants("StateSpecialty") _
                                 Where r.Attribute("state").Value = _state _
                                 And r.Attribute("specialty").Value = "L&D"
                                 Select r

Open in new window


...do you still have the error?

One thing I just thought of:  Is this an ASP.NET application? If so, is this query in the markup or the code-behind?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:lrbrister
ID: 40018583
Kaufmed..
Yes..  vb.net

Code Behind
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40018595
If the query is in code-behind, then there should not be an issue. If you are working in the markup, then there could be an issue with encoding, since the ASP.NET markup is (last I recall) XHTML-based.
0
 

Author Comment

by:lrbrister
ID: 40018631
kaufmed...
Taking a look at that when I get back in the office tomorrow.
0
 

Author Closing Comment

by:lrbrister
ID: 40032425
Duh in me...had a typo
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question