SolvedPrivate

Handle Ampersand in XML Linq

Posted on 2014-04-23
7
25 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
  • 4
  • 3
7 Comments
 
LVL 74

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 74

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

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

Code Behind
0
 
LVL 74

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now