1

I am trying to send a value like <Somevalue = "Value A/B"> through XML.As "/" comes under illegal character,I tired to encode like &frasl; for slash but it is not working.Is there anyway to do the same?

Pavan
  • 85
  • 1
  • 3
  • 7

3 Answers3

11

The xml sample you have given there is not valid, irrespective of the slash (which is valid)

I'm guessing it should either be something like

<Somevalue>Value A/B</Somevalue>

OR

<Somevalue value="Value A/B"/>

In any case - until you fix your xml, it won't work.

Rob Levine
  • 40,328
  • 13
  • 85
  • 111
  • Well spotted - maybe the 'Illegal Character' is actually relating to invalid syntax, i.e. an equals sign where an attribute name should be. – DilbertDave Aug 07 '09 at 08:47
  • 2
    I say we take off and nuke the site from orbit. – skaffman Aug 07 '09 at 08:47
  • You are right,but I just gave some example.The XML is working fine without slash.If I include slash I am getting Illegal Characters messages.The same value I can enter through front end without any problem. – Pavan Aug 07 '09 at 08:47
  • 2
    Can you post a bit of the actual XML you are using - in context. – DilbertDave Aug 07 '09 at 08:53
  • 1
    "Just giving some example" which doesn't actually represent what you're doing isn't terribly useful. @DilbertDave is exactly right - you need to give a *real* example. You also still haven't said what you're doing with this XML. – Jon Skeet Aug 07 '09 at 10:37
6

"/" isn't an illegal character in XML at all. It may be illegal for the particular service you're using, however.

Could you give more context? I strongly suspect this isn't really an XML question, but a service-specific question. I suspect if you look at the error message you're getting, it will talk about invalid values rather than illegal XML. (If you could post that error message in full, it would be helpful too.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
2

Forwardslash isn't a special character in XML. The snipped you posted is well-formed. What's saying it's illegal?

You could try using &#x2F; (2F being the hex for the ASCII character code for the forwardslash character).

Iain Galloway
  • 18,669
  • 6
  • 52
  • 73