Can someone please help me out here.. I am trying to convert a .xml
file to .dtd file.. I got this .xml file from google.
<?xml version="1.0"?>
<book>
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>
<person>
<first>Bill</first>
<last>Gates</last>
<age>46</age>
</person>
<person>
<first>Steve</first>
<last>Jobs</last>
<age>40</age>
</person>
</book>

Please could you help me out using this example to convert this .XML to .DTD file. I don't know how to do it and I wanna know please...You can use any example that you want..Thank you in advance..

Well, are you trying to write a java program that converts Xmls to DTDs ?!
Reason why I ask is it's not a good idea.
Do you know what is a DTD used for and what is it's syntax?

No im not trying to write a java program.. I was given an assignment which is below:
Change the programs that you wrote for the Coursework 2 so that recipes
are stored as .XML les rather than as simple text or as serialized objects.
You should not need to change any other part of your existing program: just
change the section in the recipe program that writes recipes out to use XML,
and include an XML parser in the menu program for reading them back.
Students who did not manage to get the programs for Coursework 2 to
work should write a program that creates recipes from arrays of Strings
and use these.
(2) Write a .DTD le that species what the contents of the .XML les
should look like, and a .XSL le which turns the .XML le into appropriate
.HTML.

I have already converted the java program to .xml and the next part is to .dtd but Im stuck and i dont know how to do it..thats why i used the example from google so that you wouldn't think i want you to do the assignment for me.. I hope you can help me now..

You didn't answer my question.. ( Do you know what is a DTD used for and what is it's syntax?) so i'll assume answer is no..
Well, DTD is the Document Type Definition, that describes the format of an XML file. If you know Java/C++ a crude example would be see DTD as a class and XML as class object/instance.
So what you should do:
0. List down teh data you wanna put in your XML file.
1. At least get an overview of what is a DTD. Look at external links section for details.
2. Learn how to write a DTD.
3. Then write the DTD.
4. Then write an XML file that conforms to this DTD.

For teh HTML part of your problem see this link.

Finally always remember to search wikipedia.

ok..thank you for that

hello there...for ur documnet it will be like this...
<!DOCTYPE book[
<!ELEMENT book (person)+>
<!ELEMENT person (first,last,age)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT age (#PCDATA)>

]>

<book>
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>

<person>
<first>Bill</first>
<last>Gates</last>
<age>46</age>
</person>

<person>
<first>Steve</first>
<last>Jobs</last>
<age>40</age>
</person>

</book>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.