473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 2119
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 image or a text. This is a URL that returns 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 is still a pretty new area to me... (been working...
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 attrib { var $lenght; var $type; ... }
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 win user acceptance and subsequent marketability....
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? I have someone who is good at designing, but...
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 postback. I am assuming that there is some difference,...
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. What we have today are traditional BI tools that...
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 it with the e3c validator and it says: " This...
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 the same. I have discovered, to my chagrin,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.