SolvedPrivate

Handle Ampersand in XML Linq

Posted on 2014-04-23
7
27 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 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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