XML -URL help

Caporegime
Joined
18 Oct 2002
Posts
32,650
I'm making an XML document and a corresponding DTD.
Most of it is fine but I am having a problem with some URLs/URIs

I have defined a 'webPage' element as plain text:
<!ELEMENT webPage (#PCDATA)>
I expect there is a better way of properly specifiying a URL but it isn't massively important for this- plain text will suffice.


In my XML documnet I can specify conventional URLs fine e.g:
http://www.theonering.net/movie/char/legolas.html

but a lot of my URLs are of the form:
http://www.allmovie.com/cg/avg.dll?p=avg&sql=B77309

this doesn't seem to wor but the error message is a bit useless. What does one do to make this kind of URL work. As I said having it as plain text is acceptable but for some reason it can't read that as plain text.

XML/HTML Noob here! :D
 
bumping this:


here is the DTD tags adn an extract of the XML-
Code:
<!ELEMENT personalDetails (name+, nationality?, dateOfBirth?, sex, webPage*)>
<!ELEMENT webPage (#PCDATA)>


// ##########XML doc#################

<personalDetails>
	<name>
	        <firstName>Elijah</firstName>
		<surName>Wood</surName>
	</name> 
	<dateOfBirth>
		<date>
			<day>28</day>
			<month>1</month>
			<year>1981</year>
		</date>
	</dateOfBirth>  
	<sex><male/></sex> 
						<webPage>http://www.allmovie.com/cg/avg.dll?p=avg&sql=B77309</webPage>
					</personalDetails>

This is the error that firefox gives:
Code:
XML Parsing Error: not well-formed
Location: file:///C:/Documents%20and%20Settings/Tim%20Stirling/Desktop/courses/semester%202/MASWS/LOTR_FOTR.xml
Line Number 26, Column 60:						      
<webPage>http://www.allmovie.com/cg/avg.dll?p=avg&sql=B77309/</webPage>
-----------------------------------------------------------^
but with the arrow pointing to the second 't' of http.
 
Last edited:
It's likely to be the ampersand that's causing the problem. &, <, >, ' and " are all special reserved characters in XML and must be converted to their entity equivalent to be used in values - & must be entered as &amp;

Code:
<webPage>
  http://www.allmovie.com/cg/avg.dll?p=avg[b]&amp;[/b]sql=B77309
</webPage>

Alternatively, for convenience, you can place strings with lots of those characters in CDATA blocks:

Code:
<webPage>
  <![CDATA[http://www.allmovie.com/cg/avg.dll?p=avg&sql=B77309]]>
</webPage>
 
Back
Top Bottom