emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drop toplevel XML-comments in libxml-parse-(xml|html)-region?


From: Ulf Jasper
Subject: Drop toplevel XML-comments in libxml-parse-(xml|html)-region?
Date: Tue, 28 Oct 2014 21:36:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Hi,

parse_region from xml.c, which is called by `libxml-parse-xml-region'
and `libxml-parse-html-region', makes some effort to retain top-level
comments in xml documents.  If necessary it adds an artificial node at
the top of the parse tree.  As a consequence one has to check whether
the result contains the "top" node or not (see below for an example).
This behaviour is different from that of `xml-parse-region' (from
xml.el), which just discards the toplevel comments.

Can we make `libxml-parse-(xml|html)-region' consistent with
`xml-parse-region', i.e. can we drop the toplevel xml comments (and
simply call xmlDocGetRootElement)?

Ulf

----------------------------------------------------------------------
Example: Calling (libxml-parse-xml-region (point-min) (point-max)) on

<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>
<!--ignore me-->
    
results in

    (top nil (foo nil "bar") (comment nil "ignore me"))

while for

<?xml version="1.0" encoding="UTF-8"?>
<foo>bar</foo>
    
one gets

    (foo nil "bar")

without the artificial node "top".


reply via email to

[Prev in Thread] Current Thread [Next in Thread]