Entity References?

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.
ogeikemAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

functionpointerCommented:
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
ogeikemAuthor Commented:
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
functionpointerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.