newbie questions on XML- attribute, data with multiple lines

L

liu

I just started using XML. I have 2 basic questions:

1) What is the benefit of using attribute compared to include the
content in another item under the element?
For example, I have numbers for different entries of elements.
I can have:
<element1>
<no>1</no>
<data1>text here</data1>
<data2>text here</data2>
</element1>

Or, I can have:
<element1 no = '1'>
<data1>text here</data1>
<data2>text here</data2>
</element1>

How do I decide choosing one over the other?

Also I have data spread over multiple lines. Is it OK to just spread it
over multiple lines. Will ASP have problem parsing the data?

for example:
<data3>
Fetal Ventricles: Normal
Fetal Cerebellum: Normal
Fetal Cranium: Normal
</data3>

Thanks for help,


liu
 
J

Joe Kesselman

liu said:
Also, how to get special characters in, such as ü?

Specify the encoding as one that supports those characters (and make
sure your parser supports that encoding -- if in doubt, UTF-8 and UTF-16
are supported by almost every XML tool), or use a numeric character
reference if you need to refer to a character that isn't in the file's
encoding.
 
L

liu

Joe said:
Specify the encoding as one that supports those characters (and make
sure your parser supports that encoding -- if in doubt, UTF-8 and UTF-16
are supported by almost every XML tool), or use a numeric character
reference if you need to refer to a character that isn't in the file's
encoding.

Thanks for the help. Also I didn't add ecoding information, and it does
not like special ' or " that generated with Microsoft Word. By adding
<?xml version="1.0" encoding="ISO-8859-1"?>, it does not prompt the
"invalid character" message with XML Notepad but it does not support
UTF-8 or UTF-16.

Of all the encoding methods, which one should I use?
<?xml version="1.0" encoding="windows-1252"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-16"?>

Thanks for the help,
 
J

Joe Kesselman

liu said:
Thanks for the help. Also I didn't add ecoding information, and it does
not like special ' or " that generated with Microsoft Word.

Word's "smart quotes" are an unmitigated disaster. The best advice I can
give you is to use another editor -- almost any other editor -- when
working on documents intended to be read by anything other than humans.
Of all the encoding methods, which one should I use?

Whichever encoding your document was saved in. If it's an ASCII file,
ASCII is a subset of any of the first three of those so any of them
should work. But you really do need to use the right quote character.
 
A

Alan J. Flavell

Word's "smart quotes" are an unmitigated disaster. The best advice I
can give you is to use another editor -- almost any other editor --
when working on documents intended to be read by anything other than
humans.

Indeed! An alternative was to hunt through the options, and whenever
you see the term "smart" or "clever" or anything resembling it,
disable the option. However, in later versions they've sprinkled the
various nannying options amongst a whole lot of different option
menus.

In Office 2003 it's been hidden away in Tools> AutoCorrect Options>
Autoformat as you type. This whole area reeks of Nanny Gates, and
anyone who knows what they're doing, and wants to do it without MS
continually contradicting them, would be well advised to turn the lot
off, IMNSHO.
Whichever encoding your document was saved in. If it's an ASCII
file, ASCII is a subset of any of the first three of those so any of
them should work. But you really do need to use the right quote
character.

If it's to be saved as ASCII and I've understood your intention, then
surely they can't help getting the right quote character? The "smart"
quotes aren't in the ASCII repertoire. It would be impossible to save
them in ASCII (properly so called).

best regards
 
J

Joe Kesselman

Alan said:
If it's to be saved as ASCII and I've understood your intention, then
surely they can't help getting the right quote character?

True, IF folks are using genuine ASCII. I don't particularly trust the
end-user's ability to persuade Word to do so. YMMV.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top