Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

valid XML syntax ????? ...HELP me!!! 2

Status
Not open for further replies.

qajussi

Programmer
Joined
Mar 22, 2004
Messages
236
Location
US
Hi!

I am extracting data from the access database.
I know some XML but don't know how to handle this.
I am throwing XML tags around each value of fields from the table..
The field name is short abbreviation.
I need to add some reasonable description.
How should I do this ??
Here is what I am trying to do.

I have a table:
tbleAgent
--------
field name1 RefID
field name2 AgentName
field name3 Decription
field name4 CharDetail
...
etc

OK first three field names pretty short and straight forward. So I can use them in XML tag.
<Agent>
<RefID>2</RefID>
<AgentName>anthrax</AgentName>
<Decription>Chemical agent.......etc.....</Decription>
<CharDetail>blah blah...etc </CharDetail>

I am using the fieldnames as XML tags <RefID><AgentName>...etc. when I do the extraction from the table..

How can I add a short decription to it..???

See <CharDetail> is too short and it is not too obvious to other people that it is "Characteristic Detail"
I can't just use it as <CharacteristicDetail> (I guess this one short enough) but what about other longer description??

Can you help?? i don't think I explained right...
Sorry..

SHould I code like this??
<RefID_detail>
<Agent>
<RefID_detail>Reference ID</RefID_detail>
<RefID>2</RefID>
<AgentName_detail>Agent Name</AgentName_detail>
<AgentName>anthrax</AgentName>
<Description_detail>Description</Description_detail>
<Description>Chemical agent.......etc.....</Description>
<CharDetail_detail>Characteristic Detail</CharDetail_detail>
<CharDetail>blah blah...etc </CharDetail>
</agent>

Does this make any sense??

Thank you for your help in advance.


 
Don't do that: you'll just confuse the issue. This is one of the few instances where I'd accept the use of attributes, like so:

Code:
<Agent>
<RefID description="Reference ID">2</RefID>
<AgentName description="Agent Name">anthrax</AgentName>
<Decription description="Decription">Chemical agent.......etc.....</Decription>
<CharDetail description="Characteristic Detail">blah blah...etc </CharDetail>

Do try to spell tag/attribute names correctly, otherwise you will cause yourself and your users no end of headaches.
 
Thank you harebrain.

I thought about the attibute but I wasn't too sure how I should use it.

I will follow your advise.
Thank you again




 
Are you talking about describing what the <CharDetail> tag means, or are you talking about further describing the content of each <CharDetail> element?

If you want to describe the structure of your XML document, and what all the bits and pieces mean, the best place to do it would be in an attached DTD (Document Type Definition) or XML:Schema document. It'll allow readers to validate your XML too.

Failing that, put a big comment near the top of your document explaining what's what. Don't go adding extra data elements to describe your main data elements.

-- Chris Hunt
 
Hi Chris Hun!

Thank you for your help.

I guess what I am trying to do is include the description for the content.

Another person has to create the webpages from this XML file.

<CharDetail>Blue, stinky.......etc.......brown color</CharDetail>

He has to know what "Blue, stinky.......etc.......brown color" came from. HE will know it was tagged with "CharDetail" and I don't want him to spend time trying to figure out what "CharDetail" could be.

He has to put
"Characteristics Detail:
Blue, stinky.......etc.......brown color" on the web page.

Should I tag it like
<Char Detail Description="Characteristic Detail">??

Or Should I do it with DTD as you said???

can you advise ??
Maybe can you post a simple example here??
Thank yo.
 
Put it in the DTD - it's there to describe the structure of the document. Alternatively, write a document in plain english (or whatever language) and pass this on to your colleague.

Frankly the combination of reasonably descriptive tag names and the actual values of the data are generally enough to figure out what's going on. You're probably worrying unnecessarily.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top