• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

Passing & as a parameter in string

Hello,
I have a message in XML format and I am retreiving data from each element of the XML using XPATH in Biztalk.I am now passing this data as parameters where I want to do additional manipulation to the data.
One of my string parameter values is coming as "EK &SONS INC" and when I try to pass this as it is in string format in a method call, I get the following error: "System.Xml.XmlException: An error occurred while parsing EntityName"
I have even tried to replace the & with &
Please suggest what should  I do to format the string such that  the '&' is retained in the string and the method call is successful.
I am using C#.NEt for coding
0
subhorachana
Asked:
subhorachana
1 Solution
 
subhorachanaAuthor Commented:
it is in c# programming zone.
0
 
VenabiliCommented:
It was not- I added it there when I posted the above message :)
It was only in Microsoft Development, Programming Languages
0
 
MogalManicCommented:
Could we see some sample code?

Possibly the full stack trace?
0
 
subhorachanaAuthor Commented:
exact location of code where I am getting the error:I am trying to create an XML as one of the parameter for Web service.It throws an error while creating the XML.
batchElement.InnerXml = "<Method ID='1' Cmd='New'>" +
               "<Field Name='Title'>APIS</Field>" +
               "<Field Name='Status'>Pending</Field>" +
              "<Field Name='Number'></Field>" +
              "<Field Name='EffecitveDate'>adsafsa</Field>" +
              "<Field Name='ExpirationDate'></Field>" +
              "<Field Name='Named'>EK &amp;SONS INC</Field>" +
              "<Field Name='NamedICity'>Chicago</Field>" +
              "<Field Name='NamedZIP'>60611</Field></Method>"
0
 
Tony McCreathTechnical SEO ConsultantCommented:
I would use the dom objects to add your elements instead of hand writing the XML as a string. This way the dom objects will make sure your text is encoded correctly and your xml is well formatted.
XmlElement methodElement = xmlDoc.CreateElement("Method");
batchElement.AppendChild(methodElement);
 
XmlElement fieldElement = xmlDoc.CreateElement("Field");
fieldElement.SetAttribute("Name","Named");
fieldElement.InnerText = "EK &amp;SONS INC";
methodElement.AppendChild(fieldElement);

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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