Altova Mailing List Archives>Archive Index >xml-dev Archive Home >Recent entries >Thread Prev - Re: [xml-dev] How to parse XML document with default namespace with [Thread Next] Re: [xml-dev] How to parse XML document with default namespace withTo: Jack Bush <netbeansfan@-----.---.--> Date: 11/6/2008 9:12:00 AM hi,
another piece of code that might be useful:
<xcl:active-sheet
xmlns:xcl="http://ns.inria.org/active-tags/xcl"
xmlns:ns="http://www.w3.org/1999/xhtml">
<xcl:parse-html name="myHtml" source="file:///path/to/file.html"/>
<xcl:for-each name="myElem" select="{
$myHtml/ns:html/ns:body/ns:div[@id='container']/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a
}">
<xcl:echo value="{ string( $myElem ) }"/>
<xcl:echo value="{ string( $myElem/@href ) }"/>
</xcl:for-each>
</xcl:active-sheet>
the underlying HTML parser is not tagsoup but nekohtml; if your source
file is XHTML and not HTML, you can simply use <xcl:parse> (an XML
parser) instead of <xcl:parse-html> (an HTML parser)
I don't really know what happens for a pure HTML source with the XHTML
namespace, but you can trace what have been parsed by inserting the
following operation, for example after the for-each statement:
<xcl:transform source="{ $myHtml }" output="{ $sys:out }"
xmlns:sys="http://ns.inria.org/active-tags/sys"/>
for pure HTML sources, nekohtml capitalize the elements to be conform to
the HTML spec (as stated in the nekohtml parser documentation), and it
must be the same in the XPath expression
to launch the script, just download reflex
(http://reflex.gforge.inria.fr/) and type in a console:
java -jar reflex-0.3.2.jar run active-sheet.xcl
--
Cordialement,
///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
