Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 57
  • Last Modified:

Handle Ampersand in XML Linq

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
Larry Brister
Asked:
Larry Brister
  • 4
  • 3
1 Solution
 
käµfm³d 👽Commented:
So filling _specialty with "L&D" doesn't work?
0
 
Larry Bristersr. DeveloperAuthor Commented:
I get the red underline and this message on mouse over

specialty="L&D"

"Entity D is not defined
0
 
käµfm³d 👽Commented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Larry Bristersr. DeveloperAuthor Commented:
Kaufmed..
Yes..  vb.net

Code Behind
0
 
käµfm³d 👽Commented:
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
 
Larry Bristersr. DeveloperAuthor Commented:
kaufmed...
Taking a look at that when I get back in the office tomorrow.
0
 
Larry Bristersr. DeveloperAuthor Commented:
Duh in me...had a typo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now