Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

CDATA XML and XHTML

Hi,

I was reading as below

if you write a JavaScript code inside a XHTML web page (without using the CDATA section) you have to escape those characters.

Open in new window


  //if (node instanceof Element && node.getNodeName().equalsIgnoreCase("name")) {//did not work in java
   if (node instanceof Element && node.getNodeName().equalsIgnoreCase("name")) {//worked in java

what is CDATa. when we use CDATA section. How CDATA related to XML or XHTML. How XML and XHTML are similar or different. when to use which one. How to write CDATA for given XML. Does SOPA UI needed request within CDATA all the time to get web service response?

Please advise
SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

3. Be enclosed in a CDATA section. You won't need to escape the mark up characters individually and the content won't be dropped on parsing.

is JSP(java server pages similar to CDATA where we write html inside java using different things like scriptlets like

<!=
<%

etc
If there is XML why we need XHTML again. please advise
I'm not familiar with JSP, but I believe they (as well as the classic ASP) are not XML, so there are different rules of escaping things.
XML is a common formatting (or syntax) standard with a great number of different implementations, each of them has its own set of tag names and its own purpose. XHTML is one of them. The purpose of XHTML is be rendered by a web browser and be able to be read by an XML parser (regular HTML can not be read by an XML parser, because in general, it's not well-formed (special characters are not escaped, some tags might be not closed, etc.)
XML is a generic strict markup language.  XHTML uses a strict syntax from XML, but using HTML tags

The following code is only valid in HTML : SCRIPT content with special chars (& > < ) are valid

<SCRIPT type="text/javascript">

if ( var1 == 1 && var2 ==2 ) var3=0;

</SCRIPT>

Open in new window


To make this code "XHTML valid" you need to use CDATA delimiters to allow free code into the content tag (content is not parsed as XML/XHTML):

<SCRIPT type="text/javascript"><![CDATA[

if ( var1 == 1 && var2 ==2 ) var3=0;

]]></SCRIPT>

Open in new window


Generally, in XML / XHTML you need to follow the XML syntax rules  to avoid parsing errors.
http://www.w3schools.com/xml/xml_syntax.asp
Avatar of gudii9

ASKER

SOAP UI  wev service requests cannot take XML but only takes xHTML as request? please advise
SOAPUI request are written in XML format using the SOAP XML rules and format given by the target web service (defined in a WSDL document )

You can try using soap ui with public web services and see the format in auto-generated requests:
Eg: http://www.w3schools.com/webservices/tempconvert.asmx?WSDL
Avatar of gudii9

ASKER

SOAP XML rules and format given by the target web service (defined in a WSDL document )

where it is given in below wsdl?

http://www.w3schools.com/webservices/tempconvert.asmx?WSDL

please advise
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial