Install libxml2 on windows

The XML C parser and toolkit of Gnome

Downloads

Main Menu
  • Home
  • Reference Manual
  • Introduction
  • FAQ
  • Developer Menu
  • Reporting bugs and getting help
  • How to help
  • Downloads
  • Releases
  • XML
  • XSLT
  • Validation & DTDs
  • Encodings support
  • Catalog support
  • Namespaces
  • Contributions
  • Code Examples
  • API Menu
  • XML Guidelines
  • Recent Changes
Related links
  • Mail archive
  • XSLT libxslt
  • DOM gdome2
  • XML-DSig xmlsec
  • FTP
  • Windows binaries
  • Solaris binaries
  • MacOsX binaries
  • lxml Python bindings
  • Perl bindings
  • C++ bindings
  • PHP bindings
  • Pascal bindings
  • Ruby bindings
  • Tcl bindings
  • Bug Tracker

The latest versions of libxml2 can be found on the xmlsoft.org server ( FTP and rsync are available), there are also mirrors (France and Antonin Sprinzl also provide a mirror in Austria). (NOTE that you need both the libxml(2) and libxml(2)-devel packages installed to compile applications using libxml if using RPMs.)

You can find all the history of libxml(2) and libxslt releases in the old directory. The precompiled Windows binaries made by Igor Zlatovic are available in the win32 directory.

  • RPMs for x86_64 are available directly on xmlsoft.org, the source RPM will compile on any architecture supported.
  • Igor Zlatkovic is now the maintainer of the Windows port, he provides binaries.
  • OpenCSW provides Solaris binaries.
  • Steve Ball provides Mac Os X binaries.
  • The HP-UX porting center provides HP-UX binaries
  • Bull provides precompiled RPMs for AIX as patr of their GNOME packages

If you know other supported binary ports, please contact me.

  • Code from the GNOME GIT base libxml2 module, updated hourly libxml2-git-snapshot.tar.gz.
  • Docs, content of the web site, the list archive included libxml-docs.tar.gz.

I do accept external contributions, especially if compiling on another platform, get in touch with the list to upload the package, wrappers for various languages have been provided, and can be found in the bindings section

Libxml2 is also available from GIT:

See libxml2 Git web. To checkout a local tree use:

  • The libxslt module is also present there.
  • Библиотека libxml2 для работы с XML-файлами

    Программисту часто бывает нужно работать с XML-документами. Самой популярной библиотекой для этого является libxml2. Научимся ее подключать к своему проекту.

    1. Что такое libxml2?

    libxml2 — это библиотека для парсинга XML-документов. Это означает,что программист может искать и править отдельные атрибуты и значения в XML-документе.

    Библиотека написана на языке Си, и, вследствие этого, переносима практически на все платформы (Unix, Windows, CygWin, Mac OS, RISC OS, OS/2, VMS, QNX, MVS и т.д.).

    Кроме того, существуют привязки к языкам C++, Python, PHP5 и т.д.

    Библиотека распространяется под MIT-лицензией, что делает эту библиотеку весьма популярной.

    2. Загрузка библиотеки

    Библиотеку libxml2 в формате готовых файлов можно загрузить на сайте: www.zlatkovic.com/projects/libxml/index.html

    Нужно учесть, что файлы имеют зависимости, поэтому для выбора загружаемых файлов нужно их учитывать:

    Мы видим, что в минимальном варианте нужно загрузить следующие пакеты:

    Заходим на www.zlatkovic.com/pub/libxml/ и загружаем три архива:

    Распаковываем эти архивы в папку с CodeBlocks. В каждом архиве содержатся папки bin (исполняемые модули), lib (статические библиотеки) и include (заголовочные файлы).

    Цифры в названиях можно убрать для удобства:

    3. Создание проекта

    Сначала создаем обычный консольный проект как здесь. Назовем проект x1. Затем вместо примера вставим следующий код:

    Installing lxml, libxml2, libxslt for Python 3.5 on Windows 10

    I first try to run the basic pip install command for it:

    I tried to install libxml2:

    And I also tried to install libxslt:

    I also tried to build lxml from sources ( https://github.com/lxml/lxml ) but it needs the libxml2 dependencies as well.

    I tried to install it with wheel as well after downloading the lxml file from http://www.lfd.uci.edu/

    It seems that this wheel file doesn’t support either Windows 10 or Python 3.5.

    Any help will be appreciated.

    2 Answers 2

    lxml uses libxml2 , libxslt (in background) but libxml2 , libxslt are not Python modules — it’s C/C++ libraries. So you can’t install them using pip. You have to download and install them manually.

    • cp35 in file name means version for Python 3.5.
    • win32 in file name means version for 32bit Python.
    • amd64 in file name means version for 64bit Python.

    You probably use 32bit Python because I see 32 and (x86) in your path

    You should find links to libxml2 , libxslt on this page too. This libraries has .dll and .exe files and you can put them in any folder which is in PATH variable. Libraries mostly are installed in C:\Windows or in subfolder.

    libxml2 , libxslt may have also C/C++ header files *.h which you may need when you compile lxml . (on Linux this files are in separated packages libxml2-dev , libxslt-dev )

    Installing lxml

    lxml is generally distributed through PyPI.

    Most Linux platforms come with some version of lxml readily packaged, usually named python-lxml for the Python 2.x version and python3-lxml for Python 3.x. If you can use that version, the quickest way to install lxml is to use the system package manager, e.g. apt-get on Debian/Ubuntu:

    For MacOS-X, a macport of lxml is available. Try something like

    To install a newer version or to install lxml on other systems, see below.

    Requirements

    You need Python 2.7 or 3.4+.

    Unless you are using a static binary distribution (e.g. from a Windows binary installer), lxml requires libxml2 and libxslt to be installed, in particular:

    • libxml2 version 2.9.2 or later.
    • libxslt version 1.1.27 or later.
      • We recommend libxslt 1.1.28 or later.

    Newer versions generally contain fewer bugs and are therefore recommended. XML Schema support is also still worked on in libxml2, so newer versions will give you better compliance with the W3C spec.

    To install the required development packages of these dependencies on Linux systems, use your distribution specific installation tool, e.g. apt-get on Debian/Ubuntu:

    For Debian based systems, it should be enough to install the known build dependencies of the provided lxml package, e.g.

    Installation

    If your system does not provide binary packages or you want to install a newer version, the best way is to get the pip package management tool (or use a virtualenv) and run the following:

    If you are not using pip in a virtualenv and want to install lxml globally instead, you have to run the above command as admin, e.g. on Linux:

    To install a specific version, either download the distribution manually and let pip install that, or pass the desired version to pip:

    To speed up the build in test environments, e.g. on a continuous integration server, disable the C compiler optimisations by setting the CFLAGS environment variable:

    (The option reads «minus Oh Zero», i.e. zero optimisations.)

    MS Windows

    For MS Windows, recent lxml releases feature community donated binary distributions, although you might still want to take a look at the related FAQ entry. If you fail to build lxml on your MS Windows system from the signed and tested sources that we release, consider using the binary builds from PyPI or the unofficial Windows binaries that Christoph Gohlke generously provides.

    Linux

    On Linux (and most other well-behaved operating systems), pip will manage to build the source distribution as long as libxml2 and libxslt are properly installed, including development packages, i.e. header files, etc. See the requirements section above and use your system package management tool to look for packages like libxml2-dev or libxslt-devel . If the build fails, make sure they are installed.

    Alternatively, setting STATIC_DEPS=true will download and build both libraries automatically in their latest version, e.g. STATIC_DEPS=true pip install lxml.

    MacOS-X

    On MacOS-X, use the following to build the source distribution, and make sure you have a working Internet connection, as this will download libxml2 and libxslt in order to build them:

    Building lxml from dev sources

    If you want to build lxml from the GitHub repository, you should read how to build lxml from source (or the file doc/build.txt in the source tree). Building from developer sources or from modified distribution sources requires Cython to translate the lxml sources into C code. The source distribution ships with pre-generated C source files, so you do not need Cython installed to build from release sources.

    If you have read these instructions and still cannot manage to install lxml, you can check the archives of the mailing list to see if your problem is known or otherwise send a mail to the list.

    Using lxml with python-libxml2

    If you want to use lxml together with the official libxml2 Python bindings (maybe because one of your dependencies uses it), you must build lxml statically. Otherwise, the two packages will interfere in places where the libxml2 library requires global configuration, which can have any kind of effect from disappearing functionality to crashes in either of the two.

    To get a static build, either pass the —static-deps option to the setup.py script, or run pip with the STATIC_DEPS or STATICBUILD environment variable set to true, i.e.

    The STATICBUILD environment variable is handled equivalently to the STATIC_DEPS variable, but is used by some other extension packages, too.

    Source builds on MS Windows

    Most MS Windows systems lack the necessarily tools to build software, starting with a C compiler already. Microsoft leaves it to users to install and configure them, which is usually not trivial and means that distributors cannot rely on these dependencies being available on a given system. In a way, you get what you’ve paid for and make others pay for it.

    Due to the additional lack of package management of this platform, it is best to link the library dependencies statically if you decide to build from sources, rather than using a binary installer. For that, lxml can use the binary distribution of libxml2 and libxslt, which it downloads automatically during the static build. It needs both libxml2 and libxslt, as well as iconv and zlib, which are available from the same download site. Further build instructions are in the source build documentation.

    Source builds on MacOS-X

    If you are not using macports or want to use a more recent lxml release, you have to build it yourself. While the pre-installed system libraries of libxml2 and libxslt are less outdated in recent MacOS-X versions than they used to be, so lxml should work with them out of the box, it is still recommended to use a static build with the most recent library versions.

    Библиотека libxml2 для работы с XML-файлами

    Программисту часто бывает нужно работать с XML-документами. Самой популярной библиотекой для этого является libxml2. Научимся ее подключать к своему проекту.

    1. Что такое libxml2?

    libxml2 — это библиотека для парсинга XML-документов. Это означает,что программист может искать и править отдельные атрибуты и значения в XML-документе.

    Библиотека написана на языке Си, и, вследствие этого, переносима практически на все платформы (Unix, Windows, CygWin, Mac OS, RISC OS, OS/2, VMS, QNX, MVS и т.д.).

    Кроме того, существуют привязки к языкам C++, Python, PHP5 и т.д.

    Библиотека распространяется под MIT-лицензией, что делает эту библиотеку весьма популярной.

    2. Загрузка библиотеки

    Библиотеку libxml2 в формате готовых файлов можно загрузить на сайте: www.zlatkovic.com/projects/libxml/index.html

    Нужно учесть, что файлы имеют зависимости, поэтому для выбора загружаемых файлов нужно их учитывать:

    Мы видим, что в минимальном варианте нужно загрузить следующие пакеты:

    Заходим на www.zlatkovic.com/pub/libxml/ и загружаем три архива:

    Распаковываем эти архивы в папку с CodeBlocks. В каждом архиве содержатся папки bin (исполняемые модули), lib (статические библиотеки) и include (заголовочные файлы).

    Цифры в названиях можно убрать для удобства:

    3. Создание проекта

    Сначала создаем обычный консольный проект как здесь . Назовем проект x1. Затем вместо примера вставим следующий код:

    void parseStory(xmlDocPtr doc, xmlNodePtr cur)

    while (cur != NULL)

    if ((!xmlStrcmp(cur->name, (const xmlChar *)»keyword»)))

    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);

    static void parseDoc(char *docname)

    fprintf(stderr,»Document not parsed successfully. \n»);

    if (xmlStrcmp(cur->name, (const xmlChar *) «story»))

    fprintf(stderr,»document of the wrong type, root node != story»);

    while (cur != NULL)

    if ((!xmlStrcmp(cur->name, (const xmlChar *)»storyinfo»)))

    parseStory (doc, cur);

    int main(int argc, char **argv)

    printf(«Usage: %s docname\n», argv[0]);

    В этом примере мы парсим XML-документ и ищем ключ с именем «keyword». Затем выводим значение этого ключа.

    4. Настройка компилятора

    Чтобы пример заработал нужно сделать следующие три шага:

    • Указать компилятору, где взять заголовочные файлы.
    • Подключить библиотеки для компоновки.
    • Поместить библиотеки в готовый проект.

    Начнем с заголовочных файлов. Зайдите в меню «Проект — Параметры сборки — Каталоги» и добавьте пути к заголовочным файлам:

    Затем переключитесь на вкладку «Настройки компоновщика» и укажите библиотеку:

    И, наконец, скопируйте следующие файлы dll в папку с программой:

    • c:\Prog\CodeBlocks2\LibXML\bin\libxml2.dll
    • c:\Prog\CodeBlocks2\Iconv\bin\iconv.dll
    • c:\Prog\CodeBlocks2\Zlib\bin\zlib1.dll

    Эти файлы нужно скопировать в папку:

    5. Создание тестового файла

    Нам нужен XML-документ для работы. Создайте текстовый файл и скопируйте туда текст:

    Читайте также:  Как переделать драйвер для windows 10
    Оцените статью