472,348 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

design difference between xml & html

Hi
This is what I beleive. Please tell whether this is true.

Is it true that in xml we can have no text belonging to an element that
has sub elements too?
While in HTML this can be.

for eg.

<parent>
parent data
<child>
child data
</child>
</parent>

is the above valid XML ?
Thanks
Ankit Jain

Jul 20 '05 #1
3 2074
On Fri, 24 Dec 2004 22:29:14 -0800, Ankit wrote:
Is it true that in xml we can have no text belonging to an element that
has sub elements too?


No, it is not true.

You should read the XML spec. The latest edition is at

http://www.w3.org/TR/2004/REC-xml-20040204/

Look at Section 3.2.2 "Mixed Content".
Jul 20 '05 #2


Ankit wrote:

Is it true that in xml we can have no text belonging to an element that
has sub elements too?
While in HTML this can be.

for eg.

<parent>
parent data
<child>
child data
</child>
</parent>

is the above valid XML ?


You can only talk about validity of a certain XML document if you also
provide or refer to a grammar in form of a DTD or a schema which should
be used to validate the XML against it.
It is possible to write a DTD that allows that XML so that the XML is
valid according to the DTD but it is also possible to write a DTD so
that the XML is not valid according to that DTD.

If you are only asking about the well-formedness of that XML above then
yes, it is well-formed, you were only pointed to the relevant section in
the XML specification talking about mixed content.

And depending on which HTML 4 DTD for instance you use you will also
find elements whose content model is restricted to child elements while
it doesn't allow text child nodes so your understanding of HTML seems
not to be right too.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #3
Ankit wrote:
Hi
This is what I beleive. Please tell whether this is true.

Is it true that in xml we can have no text belonging to an element that
has sub elements too?
No, this is false. It's called Mixed Content and it is extremely common in
normal text documents in (for example) paragraphs.
While in HTML this can be.
Yes, exactly like HTML.
for eg.

<parent>
parent data
<child>
child data
</child>
</parent>
This is poor design. It would be better as

<parent>parent data<child>child data</child></parent>

and only insert spaces where you really need them. Mixed Content in non-text
applications ("data" XML) is very rare and probably an error.
is the above valid XML ?


Only if you have a DTD or Schema which specifies that structure.

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mattias Campe | last post by:
Hi, Depending on if I get an image or a text of a certain URL, I want to do something different. I don't know in advance whether I'll get an...
43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs...
4
by: Danimal | last post by:
I have been using PHP for a long time... since it was called PHP/FI. I have a programming design question: Let say I have this class: class...
3
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? ...
12
by: Nathan Sokalski | last post by:
What is the difference between the Page_Init and Page_Load events? When I was debugging my code, they both seemed to get triggered on every...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications....
17
by: roN | last post by:
Hi, I'm creating a Website with divs and i do have some troubles, to make it looking the same way in Firefox and IE (tested with IE7). I checked...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.