Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Entity References?

Posted on 2003-02-28
3
Medium Priority
?
292 Views
Last Modified: 2013-11-19
Please tell me under what circumstance I will need to use the < and > entity references. I read somewhere that they might come in handy when representing a path to a directory in my xml code eg

<location> Locate the web.xml file in the &lt;path&gt;/bin directory </location>

I know that this tranlates to

<location> Locate the web.xml file in the <path>/bin directory </location>

But I dont understand why you will need "non-xml" < and > tags in your xml code. Thanks.
0
Comment
Question by:ogeikem
  • 2
3 Comments
 
LVL 2

Expert Comment

by:functionpointer
ID: 8046340
if you used "<path>", the XML parser will think ( rightly so ) that 'path' is a tag. Since you dont have a "</path>" closing tag, this will cause an exception in the xml parser. For this reason, '<' and '>' are not allowed as data in XML.
Using & lt;  or & gt;  kinda sucks, because this is HTML. You might as well use ANY character or character sequence to represent your '<' and '>' as long as you know what you are looking for.  Alot of times, people will use the lt and gt because they figure, "what the hey, its all html in the end." and kill two birds with one stone, so to speak.  Personally, I see ourselves explaining this one to our kids one day. "Daddy, why do we have to use this &lt and &gt in our XML?". "Well, son. You see there was once this thing called HTML..."
Anyway, your parser will hate you for putting '<' and '>' in your data.  Unless you want to skip validation and write your own SAX handler to handle '>' and '<'. ;-)
0
 

Author Comment

by:ogeikem
ID: 8046491
Thanks for the comment. I understand how entity references were used to represent '<' and '>' in this xml code. What I dont understand is why anyone would need non-xml '<' and '>' tags in their xml code. I thought xml was used to deliver pure text and not tags.
0
 
LVL 2

Accepted Solution

by:
functionpointer earned 80 total points
ID: 8046504
I work for a company that writes applications for financial institutions. You would not believe how many times "less than" and "greater than" get passed around. Whether we like it or not, less intelligent people enter this info into other apps, it gets put in databases, and gets pulled out and put in XML documents/messages to be sent elsewhere. '>' and '<' are just ascii characters, and as long as they keep putting them on the keyboard, like sharp objects, stupid people will continue to hurt themselves.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question