delete from pattern to pattern if it contains match

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Mon Apr 25 03:17:00 EDT 2016


harirammanohar at gmail.com writes:

> Hi Jussi,
>
> i have seen you have written a definition to fulfill the requirement,
> can we do this same thing using xml parser, as i have failed to
> implement the thing using xml parser of python if the file is having
> the content as below...
>
> <!DOCTYPE web-app 
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
>     "http://java.sun.com/dtd/web-app_2_3.dtd">
>
> <web-app>
>
> and entire thing works if it has as below:
> <!DOCTYPE web-app 
> <web-app>
>
> what i observe is xml tree parsing is not working if http tags are
> there in between web-app...

Do you get an error message?

My guess is that the parser needs the DTD but cannot access it. There
appears to be a DTD at that address, http://java.sun.com/... (it
redirects to Oracle, who bought Sun a while ago), but something might
prevent the parser from accessing it by default. If so, the details
depend on what parser you are trying to use. It may be possible to save
that DTD as a local file and point the parser to that.

Your problem is morphing rather wildly. A previous version had namespace
declarations but no DTD or XSD if I remember right. The initial version
wasn't XML at all.

If you post (1) an actual, minimal document, (2) the actual Python
commands that fail to parse it, and (3) the error message you get,
someone will be able to help you. The content of the document need not
be more than "hello, world" level. The DOCTYPE declaration and the
outermost tags with all their attributes and namespace declarations, if
any, are important.



More information about the Python-list mailing list