Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Encode XML

Thread view: 
tlbollwitt@yahoo.com - 28 Jun 2006 19:51 GMT
Hello,

I'm new to the world of XML.
I have a web service that returns a String of XML data.
I need to be able to encode that String so that when it gets validated
by the client it will be in a valid XML format.

Any example would be very appreciated.

Thanks.
Tom
Oliver Wong - 28 Jun 2006 20:06 GMT
> Hello,
>
> I'm new to the world of XML.
> I have a web service that returns a String of XML data.
> I need to be able to encode that String so that when it gets validated
> by the client it will be in a valid XML format.

   I can think of two interpretations of your problems.

(1) You want have an XML document which you want to pass to the client.
Solution: just pass it to the client. Presumably, it's already valid XML, or
else that web server you have is broken.

(2) Your client is expecting a XML encoded response which semantically
represents a string. It just so happens that coincidentally, this content is
XML data.
Solution: Escape the relevant characters.

For example, if you want to return the String which represents the following
XML document:

<XmlDocument>Hello World!</XmlDocument>

then escape the string as follows:

"&lt;XmlDocument&gt;Hello World!&lt;/XmlDocument&gt;"

and then put that string within your XML response:

<XmlResponse type="string">&lt;XmlDocument&gt;Hello
World!&lt;/XmlDocument&gt;</XmlResponse>

and then your problem reduces to (1) which was already solved.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.