Hi, I am new in xml programming and I need your help.
I want to cataloging my cds and I have create a xml file and a dtd but they are not valid.
:(

xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cdcollection SYSTEM "cd-collection.dtd">

<cdcollection>
  <album barcode="">
    <title></title>
    <artist></artist>
    <track id="1"  time=""> </track>
    <track id="2"  time=""> </track>
    <track id="3"  time=""> </track>
    <track id="4"  time=""> </track>
    <track id="5"  time=""> </track>
  </album>
</cdcollection>

dtd

<!DOCTYPE cdcollection [
<!ELEMENT cdcollection (album+)>
<!ELEMENT album (title,artist,track+)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT artist (#PCDATA)>
<!ELEMENT track (#PCDATA)>
<!ATTLIST album barcode CDATA #REQUIRED>
<!ATTLIST track id CDATA #REQUIRED>
<!ATTLIST track time CDATA #REQUIRED>
]>

and how can I insert comments in xml ?
Thanks a lot

Peter,

<!-- This is a comment -->

The DTD problem is with your track+ element where you have not stated it's additional track elements, e.g.

<!ELEMENT track (element1, element2, element3) >

If you do not need any 'child' elements for the 'parent' track element, then remove the +.

See DTD examples which use the + on the w3schools website:

http://www.w3schools.com/dtd/dtd_examples.asp

It also holds a lot of useful XML information such as Syntax Rules which include how to comment, etc.

http://www.w3schools.com/xml/xml_syntax.asp

thanks a lot

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.