Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DTD validating XML HELP

    i am trying to validate my XML using the DTD but for some reason its saying 'element not declared' and im confsed, any help is appreciated thanks



    Code:
    <?xml version="1.0"?>
    
    <!DOCTYPE TVListing SYSTEM "TVListingDTD.dtd">
    
    
    <TVListing>
    		<channel channelName="BBC 1" channelNo="1" >
    			<LaunchDate>2 November 1936</LaunchDate>
    			<country>United Kingdom</country>
    			<OwnedBy>British BroadcastingCorporation</OwnedBy>
    			<Directors>
    				<name>Tony Hall</name>
    				<name>Henel Boaden</name>
    				<name>Danny Cohen</name>
    				<name>James Harding</name>	
    			</Directors>	
    		</channel>
    		<channel channelName="BBC 2" channelNo="2">
    			<LaunchDate>20 April 1964</LaunchDate>
    			<country>United Kingdom</country>
    			<OwnedBy>British BroadcastingCorporation</OwnedBy>
    			<Directors>
    				<name>Tony Hall</name>
    				<name>Henel Boaden</name>
    				<name>Danny Cohen</name>
    				<name>James Harding</name>
    			</Directors>
    		</channel>
    		<channel channelName="ITV 1" channelNo="3">
                <LaunchDate>22 September 1955</LaunchDate>
                <country>United Kingdom</country>
                <OwnedBy>ITV plc</OwnedBy>
                <Directors>
                    <name>Archie Norman</name>
                    <name>Adam Crozier</name>
                    <name>Ian Griffiths</name>
                    <name>Andy Haste</name>
                </Directors>
            </channel>
    	<programme channel="BBC 1" startTime="13 00" finishTime="13 30" series="0" episode="0">
    			<programName>BBCNewsWeather</programName>
    			<description>The latest national and international news stories from the BBC News team, followed by weather.</description>
    			<ageRating>PG</ageRating>
    			<genre>News</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>30mins</runtime>
    			<rating>3.0</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    		<programme channel="BBC 2" startTime="13 00" finishTime="13 05" series="4" episode="22">
    			<programName>Coast</programName>
    			<description>Neil Oliver visits the Oyster festival in Whitstable, Kent, then heads offshore to the Red Sands sea fort,</description>
    			<ageRating>PG</ageRating>
    			<genre>Documentary</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>5mins</runtime>
    			<rating>0.0</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    		<programme channel="ITV 1" startTime="13 00" finishTime="13 30" series="18" episode="130">
    			<programName>LooseWomen</programName>
    			<description> Andrea McLean presents topical debate from a female perspective</description>
    			<ageRating>PG</ageRating>
    			<genre>Talk Show</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>60mins</runtime>
    			<rating>3.2</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    		<programme channel="BBC 2" startTime="13 05" finishTime="13 35" series="1" episode="4">
    			<programName>SouthAfricaWalks</programName>
    			<description>Julia Bradbury's final walk is her most adventurous yet, taking her to the edge of the Kalahari Desert</description>
    			<ageRating>PG</ageRating>
    			<genre>Reality</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>30mins</runtime>
    			<rating>2.3</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    		<programme channel="BBC 1" startTime="13 30" finishTime="13 45" series="1" episode="1">
    			<programName>BBCRegionalNewsAndWeather</programName>
    			<description>The latest news, sport, weather and features from the West of England.</description>
    			<ageRating>PG</ageRating>
    			<genre>News</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>15mins</runtime>
    			<rating>0.0</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    		<programme channel="ITV 1" startTime="13 30" finishTime="13 55" series="0" episode="0">
    			<programName>ITVNewsAndWeather</programName>
    			<description>Nina Hossain with the latest headlines from around the world.</description>
    			<ageRating>PG</ageRating>
    			<genre>News</genre>
    			<HDVersion>Yes</HDVersion>
    			<runtime>25mins</runtime>
    			<rating>3.2</rating>
    			<publishedDate>28/03/2014</publishedDate>
    		</programme>
    </TVListing>
    and this is the DTD file

    <!ELEMENT TVListing (channel, programme)>
    <!ATTLIST channel channelName CDATA>
    <!ATTLIST channel channelNo ID #REQUIRED>
    <!ATTLIST programme programName CDATA>
    <!ATTLIST programme channel CDATA>
    <!ATTLIST programme startTime CDATA>
    <!ATTLIST programme finishTime CDATA>
    <!ATTLIST programme series CDATA>
    <!ATTLIST programme episode CDATA>

    <!ELEMENT channel (LaunchDate, country, OwnedBy, Directors)>
    <!ELEMENT LaunchDate (#PCDATA)>
    <!ELEMENT country (#PCDATA)>
    <!ELEMENT OwnedBy (#PCDATA)>
    <!ELEMENT Directors (Dname)>
    <!ELEMENT Dname (#PCDATA)>
    <!ELEMENT programme (programName, description, ageRating, genre, HDVersion, runtime, rating, publishedDate)>
    <!ELEMENT programName (#PCDATA)>
    <!ELEMENT description (#PCDATA)>
    <!ELEMENT ageRating (#PCDATA)>
    <!ELEMENT genre (#PCDATA)>
    <!ELEMENT HDVersion (#PCDATA)>
    <!ELEMENT runtime (#PCDATA)>
    <!ELEMENT rating (#PCDATA)>
    <!ELEMENT publishedDate (#PCDATA)>

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Try moving <!ATTLIST channel ...> after <!ELEMENT channel ...>. Ditto for the programme definitions.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •