Find Opening and Closing tags in a XML file

S

Saravan Wants

Hi All,

Is there any method to find the matching and closing tags in a XML
file? If some of tags are not closed properly, then it should be
display like missing tags. If any tool or exe file, kindly let me
know, as I am in critical situation.

Regards,
Eric
 
P

Peter Flynn

Hi All,

Is there any method to find the matching and closing tags in a XML
file?

Yes, it's called a parser. It checks the syntax of the document and
reports on any missing or badly-formed bits. All XML editors contain a
parser, so if you open the document in an XML editor it should check it
and report the errors.
If some of tags are not closed properly, then it should be
display like missing tags. If any tool or exe file, kindly let me
know, as I am in critical situation.

Hundreds. See the FAQ at http://xml.silmaril.ie/authors/parsers/

Two very reliable free stand-alone ones are onsgmls (part of the
OpenSP/OpenJade packages at http://openjade.sourceforge.net/), and RXP
(http://www.cogsci.ed.ac.uk/~richard/rxp.html). Virtually every
computing science student on the planet has had to write an XML parser
at some stage by now, I guess. There are also lots of commercial
parsers, but they tend to be embedded inside editors and other software.

///Peter
 
J

Joe Kesselman

If some of tags are not closed properly, then it should be
display like missing tags.

What does "display like missing tags" mean in this context?

Most XML parsers will not tolerate ill-formed XML, including those with
"tags" that are not properly balanced. The main exception I know is the
Tidy tool -- available from the W3C's website, among other places --
which can be told to make a "best guess" at repairing broken documents,
much as browsers tend to for broken HTML.

--
Joe Kesselman,
http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
P

Peter Flynn

What does "display like missing tags" mean in this context?

I think he means "show where there are elements with missing end-tags",
ie indicate instances of non-well-formedness.

It's sometimes amusing to confront people with fully valid HTML :)

<!doctype html public "-//IETF//DTD HTML//EN">
<title>My first web page</title>
<h1>Welcome to my site</h1>
Most XML parsers will not tolerate ill-formed XML, including those with
"tags" that are not properly balanced. The main exception I know is the
Tidy tool -- available from the W3C's website, among other places --
which can be told to make a "best guess" at repairing broken documents,
much as browsers tend to for broken HTML.

I came across a badly broken HTML instance the other day which broke
even Tidy. It was a page containing text copied and pasted from some
other source, probably an old version of word, and the chunk started
something like:

<div>
</p><p font: Verdana>text...
....
</div>

The div was generated, but the user's pasted text started with a p
end-tag, and Tidy gagged mightily on it, causing Cocoon to emit an empty
page. Quite apart from the invalid and unquoted "attributes", I've never
seen a chunk pasted from a GUI *start* with an end-tag.

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top