TheWizardofInt Posted July 5, 2005 Posted July 5, 2005 I need to pass an XML value which contains a "<" When I load the XML document containing "<", the program throws an error farther down the line, thinking that I have started a new node Is there a way to pass this value, or do I have to change the character as part of error handling? Here is an example of what I mean: <Contacts> <Contact Notes> <RecID> DJDEWYDHD>/#</RecID> <Notes> Here are some notes</Notes> </Contact Notes> </Contacts> Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Administrators PlausiblyDamp Posted July 5, 2005 Administrators Posted July 5, 2005 You should escape any non supported characters, for > use > and < for < Also your XML isn't well formed anyway as you have a space in the tag name for Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
TheWizardofInt Posted July 5, 2005 Author Posted July 5, 2005 The XML was just an example WHen you say 'escape the non-supported characters', do you mean replace them with that sort of string, or do you mean that ">" will give me the character I want? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Administrators PlausiblyDamp Posted July 5, 2005 Administrators Posted July 5, 2005 XML uses the standard HTML escape sequences for characters - just replace the non supported ones with the correct escaped character. If you are using any of the built in xml support (XmlTextWriter etc) then this should be taken care of anyway. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ZeroEffect Posted April 19, 2011 Posted April 19, 2011 I have a situation where a client doesn't want the character escaped. I am using XMLwriter and I can't seem to find a way to stop "&" from becoming "&". Is there a way to do this? This is really the onlyl character I need to do this with. Thanks Zeroeffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Leaders snarfblam Posted April 19, 2011 Leaders Posted April 19, 2011 When you encode the text into the XML, these characters should be escaped. When you read it back, you need to parse the escape sequences to get the original text. XML isn't my strong suit, but a quick google search gave me this result, which explains how to encode/decode these escape sequences. Quote [sIGPIC]e[/sIGPIC]
Administrators PlausiblyDamp Posted April 20, 2011 Administrators Posted April 20, 2011 Could you explain why they don't want this to be escaped? This is how xml works and the fact the character is escaped should be transparent to the application itself as the underlying parser should be dealing with this. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ZeroEffect Posted April 21, 2011 Posted April 21, 2011 I am told by them that that is how thier application reads and XML file. I have a feeling they are reading/loading the whole file to a string then parsing the data. I'll go at the again about correcting thier application. I have the application that generates the XML they read that XML file. I wish I knew what they were using to read it. Thanks Zeroeffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Administrators PlausiblyDamp Posted April 21, 2011 Administrators Posted April 21, 2011 I am told by them that that is how thier application reads and XML file. I have a feeling they are reading/loading the whole file to a string then parsing the data. I'll go at the again about correcting thier application. In that case they are probably not actually dealing with XML but their own XML-like syntax. If they are determined to reinvent the wheel on this one rather than use an existing and established way to do things then they are creating work for everyone. I am assuming somewhere in the spec (or what passed for a spec) the client either requested or claimed to support xml - if they are doing it themselves and breaking on simple things like this then they probably have a whole load of other problems facing them (and you), plus they are technically not supporting xml and might even be in breach of the contract. Depending on what they are after you might be able to use a CDATA section, however if they are struggling with a simple character escape sequence then I wouldn't hold my breath on them supporting this at all. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.