{"id":3871,"date":"2014-08-12T21:47:45","date_gmt":"2014-08-12T19:47:45","guid":{"rendered":"http:\/\/blog.wenzlaff.de\/?p=3871"},"modified":"2023-08-20T14:55:09","modified_gmt":"2023-08-20T12:55:09","slug":"raspberry-pi-b-wie-kann-das-schweizer-taschenmesser-xmlstarlet-1-3-1und-1-6-0-installiert-und-verwendet-werden","status":"publish","type":"post","link":"http:\/\/blog.wenzlaff.de\/?p=3871","title":{"rendered":"Raspberry Pi B+: Wie kann das Schweizer Taschenmesser xmlstarlet 1.3.1und 1.6.0 installiert und verwendet werden?"},"content":{"rendered":"<p>F\u00fcr die Bearbeitung von XML Dokumenten eignet sich gut das Programm <a href=\"https:\/\/xmlstar.sourceforge.net\/\" title=\"xmlstar\" target=\"_blank\" rel=\"noopener noreferrer\">xmlstarlet<\/a>.<br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1.png\" alt=\"xmlstarlet\" width=\"1188\" height=\"827\" class=\"aligncenter size-full wp-image-3935\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1.png 1188w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1-300x208.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1-1024x712.png 1024w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet1-900x626.png 900w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>Das xmlstarlet, kann mit seinen Abh\u00e4ngigkeiten<br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet.png\" alt=\"xmlstarlet\" width=\"1181\" height=\"208\" class=\"aligncenter size-full wp-image-3914\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet.png 1181w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet-300x52.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet-1024x180.png 1024w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/xmlstarlet-900x158.png 900w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a> wie folgt auf dem rPi installiert werden:<\/p>\n<p><code>sudo apt-get install xmlstarlet<\/code><br \/>\n<!--more--><br \/>\nNun kann die installierte Version gescheckt werden:<br \/>\n<code>pi@bplus ~ $ xmlstarlet --version<br \/>\n1.3.1<br \/>\ncompiled against libxml2 2.8.0, linked with 20800<br \/>\ncompiled against libxslt 1.1.26, linked with 10126<br \/>\n<\/code><br \/>\noder die Hilfe ausgegeben werden:<br \/>\n<code><br \/>\npi@bplus ~ $<strong> xmlstarlet --help<\/strong><br \/>\nXMLStarlet Toolkit: Command line utilities for XML<br \/>\nUsage: xmlstarlet [<options>] <command> [<cmd-options>]<br \/>\nwhere <command> is one of:<br \/>\n  ed    (or edit)      - Edit\/Update XML document(s)<br \/>\n  sel   (or select)    - Select data or query XML document(s) (XPATH, etc)<br \/>\n  tr    (or transform) - Transform XML document(s) using XSLT<br \/>\n  val   (or validate)  - Validate XML document(s) (well-formed\/DTD\/XSD\/RelaxNG)<br \/>\n  fo    (or format)    - Format XML document(s)<br \/>\n  el    (or elements)  - Display element structure of XML document<br \/>\n  c14n  (or canonic)   - XML canonicalization<br \/>\n  ls    (or list)      - List directory as XML<br \/>\n  esc   (or escape)    - Escape special XML characters<br \/>\n  unesc (or unescape)  - Unescape special XML characters<br \/>\n  pyx   (or xmln)      - Convert XML into PYX format (based on ESIS - ISO 8879)<br \/>\n  p2x   (or depyx)     - Convert PYX into XML<options> are:<br \/>\n  --version            - show version<br \/>\n  --help               - show help<br \/>\nWherever file name mentioned in command help it is assumed<br \/>\nthat URL can be used instead as well.<\/p>\n<p>Type: xmlstarlet <command> --help <ENTER> for command help<\/p>\n<p>XMLStarlet is a command line toolkit to query\/edit\/check\/transform<br \/>\nXML documents (for more information see http:\/\/xmlstar.sourceforge.net\/)<br \/>\n<\/code><\/p>\n<p>Hier nun die Anleitung, um die <strong>aktuellste<\/strong> Version <strong>1.6.0<\/strong> selbst zu erstellen:<\/p>\n<p># die alte Version wieder entfernen<br \/>\n<code>sudo apt-get remove xmlstarlet<\/code><br \/>\n# n\u00f6tige Abh\u00e4ngigkeiten installieren<br \/>\n<code>sudo apt-get install libxslt-dev libxml2-dev xml2<\/code><\/p>\n<p># neueste Version downloaden<br \/>\n<code>wget http:\/\/sourceforge.net\/projects\/xmlstar\/files\/latest\/download\/xmlstarlet-1.6.0.tar.gz<\/code><br \/>\n# archiv auspacken<br \/>\n<code>gunzip xmlstarlet-1.6.0.tar.gz<\/code><br \/>\n<code>tar xvf xmlstarlet-1.6.0.tar<\/code><br \/>\n# in das erstellte Verzeichnis wechseln<br \/>\n<code>cd xmlstarlet-1.6.0\/<\/code><br \/>\n# Version configurieren<br \/>\n<code>.\/configure<\/code><br \/>\n# Version compilieren<br \/>\n<code>sudo make<\/code><br \/>\n# Version installieren<br \/>\n<code>sudo make install<\/code><\/p>\n<p>Nun ist die Version nach <strong>\/usr\/local\/bin\/xml<\/strong> erstellt und ein<\/p>\n<p><code>\/usr\/local\/bin\/xml --version <\/code><br \/>\ngibt die Version <strong>1.6.0<\/strong> aus:<\/p>\n<p><a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-09-um-23.32.52.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-09-um-23.32.52.png\" alt=\"Bildschirmfoto 2014-08-09 um 23.32.52\" width=\"698\" height=\"103\" class=\"aligncenter size-full wp-image-3916\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-09-um-23.32.52.png 698w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-09-um-23.32.52-300x44.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/a><\/p>\n<p>Damit nicht jedesmal der Pfad mit angegeben werden muss, den Path noch <a href=\"https:\/\/wiki.debian.org\/EnvironmentVariables\" title=\"path\" target=\"_blank\" rel=\"noopener noreferrer\">exportieren<\/a>. Dazu in <strong>.bashrc<\/strong> oder f\u00fcr alle User in <strong>\/etc\/profile<\/strong> den Pfad eintragen mit:<\/p>\n<p><code>nano .bashrc<br \/>\n# xmlstarlet Path am Ende der Datei erg\u00e4nzen<br \/>\nXMLSTAR=\"\/usr\/local\/bin\/xml\"<br \/>\nexport PATH=$PATH:$XMLSTAR<\/code><\/p>\n<p>Dann einmal die Shell verlassen und neu anmelden. Testen mit <code>xml --version<\/code> und die Version 1.6.0 wird ausgegeben.<\/p>\n<p>Nun mal ein paar Beispiele f\u00fcr die Verwendung.<\/p>\n<p>Zuerst ben\u00f6tigen wir eine XML Datei zum testen. Die k\u00f6nnen wir mal mit dem Verzeichnisinhalt wie folgt erstellen.<\/p>\n<p><code>xml ls > xml-test-datei.xml<\/code><\/p>\n<p>Die hat nun folgenden Inhalt:<br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-10-um-09.09.19.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-10-um-09.09.19.png\" alt=\"test xml\" width=\"723\" height=\"536\" class=\"aligncenter size-full wp-image-3920\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-10-um-09.09.19.png 723w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-10-um-09.09.19-300x222.png 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/a><\/p>\n<p>Wir k\u00f6nnen auch die <strong>a<\/strong>, <strong>p<\/strong> und <strong>m<\/strong> Attribute entfernen, in dem wir das Ergebnis eines xmlstarlet Laufs wieder als Parameter f\u00fcr den n\u00e4chsten edit xmlstarlet Aufruf \u00fcber Pipe (|) verwenden:<br \/>\n<code>xml ls | xml ed -d \"\/\/d\" -d \"\/\/@a\" -d \"\/\/@m\" -d \"\/\/@p\"<\/code><br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.05.42.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.05.42.png\" alt=\"Bildschirmfoto 2014-08-12 um 21.05.42\" width=\"948\" height=\"905\" class=\"aligncenter size-full wp-image-3923\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.05.42.png 948w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.05.42-300x286.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.05.42-900x859.png 900w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><br \/>\nund das ganze noch mit dem ersetzen des <strong>f<\/strong> Attributs durch <strong>file<\/strong>:<br \/>\n<code>xml ls | xml ed -d \"\/\/d\" -d \"\/\/@a\" -d \"\/\/@m\" -d \"\/\/@p\" -d \"\/\/d\" -r \"\/\/f\" -v \"file\"<\/code><br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41.png\" alt=\"Bildschirmfoto 2014-08-12 um 21.14.41\" width=\"1256\" height=\"914\" class=\"aligncenter size-full wp-image-3926\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41.png 1256w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41-300x218.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41-1024x745.png 1024w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.14.41-900x654.png 900w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n<p>F\u00fcr weitere Test, holen wir uns erst einmal ein Beispiel XML:<\/p>\n<p><code>wget http:\/\/www.wenzlaff.de\/pad\/xmltocsv.xml<\/code><\/p>\n<p>Schauen wir uns nun die Struktur dieser XML Datei an mit:<\/p>\n<p><code>xml el xmltocsv.xml<\/code><\/p>\n<p>Ergebnis:<br \/>\n<code>XML_DIZ_INFO<br \/>\nXML_DIZ_INFO\/MASTER_PAD_VERSION_INFO<br \/>\nXML_DIZ_INFO\/MASTER_PAD_VERSION_INFO\/MASTER_PAD_EDITOR<br \/>\nXML_DIZ_INFO\/MASTER_PAD_VERSION_INFO\/MASTER_PAD_INFO<br \/>\nXML_DIZ_INFO\/MASTER_PAD_VERSION_INFO\/MASTER_PAD_VERSION<br \/>\nXML_DIZ_INFO\/Company_Info<br \/>\nXML_DIZ_INFO\/Company_Info\/Company_Name<br \/>\nXML_DIZ_INFO\/Company_Info\/Address_1<br \/>\nXML_DIZ_INFO\/Company_Info\/Address_2<br \/>\nXML_DIZ_INFO\/Company_Info\/Zip_Postal_Code<br \/>\nXML_DIZ_INFO\/Company_Info\/City_Town<br \/>\nXML_DIZ_INFO\/Company_Info\/Country<br \/>\n...<\/code><\/p>\n<p>Wenn die Sonderzeichen in dem XML <a href=\"https:\/\/de.wikipedia.org\/wiki\/Escape-Sequenz\" title=\"escape\" target=\"_blank\" rel=\"noopener noreferrer\">escaped<\/a> werden sollen, kann dies wie folgt geschehen:<br \/>\n<code>cat xmltocsv.xml | xml esc > xmltocsv-esc.xml<\/code><br \/>\nund schon hat man eine Datei, die man auch hier in WordPress einf\u00fcgen kann:<br \/>\n<a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11.png\" alt=\"Bildschirmfoto 2014-08-12 um 21.34.11\" width=\"1315\" height=\"426\" class=\"aligncenter size-full wp-image-3929\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11.png 1315w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11-300x97.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11-1024x331.png 1024w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2014\/08\/Bildschirmfoto-2014-08-12-um-21.34.11-900x291.png 900w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a> und als Text eingef\u00fcgt im Blog:<br \/>\n<code><br \/>\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;<br \/>\n&lt;XML_DIZ_INFO&gt;<br \/>\n\t&lt;MASTER_PAD_VERSION_INFO&gt;<br \/>\n\t\t&lt;MASTER_PAD_EDITOR&gt;DeuPAD 3.1.0.55 (http:\/\/www.deupad.org)&lt;\/MASTER_PAD_EDITOR&gt;<br \/>\n\t\t&lt;MASTER_PAD_INFO&gt;Portable Application Description, or PAD for short, is a data set that is used by shareware authors to dissemminate information to anyone interested in their software products.  To find out more go to http:\/\/www.asp-shareware.org\/pad&lt;\/MASTER_PAD_INFO&gt;<br \/>\n\t\t&lt;MASTER_PAD_VERSION&gt;3.10&lt;\/MASTER_PAD_VERSION&gt;<br \/>\n\t&lt;\/MASTER_PAD_VERSION_INFO&gt;<br \/>\n\t&lt;Company_Info&gt;<br \/>\n\t\t&lt;Company_Name&gt;Thomas Wenzlaff&lt;\/Company_Name&gt;<br \/>\n\t\t&lt;Address_1&gt;Tempelhofer Str. 9&lt;\/Address_1&gt;<br \/>\n\t\t&lt;Address_2 \/&gt;<br \/>\n...<br \/>\n<\/code><\/p>\n<p>Weitere Beispiele sind in der Anleitung zu finden. Habt Ihr noch gute Beispiele oder Anwendungsf\u00e4lle, dann hier posten.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>F\u00fcr die Bearbeitung von XML Dokumenten eignet sich gut das Programm xmlstarlet. Das xmlstarlet, kann mit seinen Abh\u00e4ngigkeiten wie folgt auf dem rPi installiert werden: sudo apt-get install xmlstarlet<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[220,808,1023,7],"tags":[1618,1619,1621,102,1620,1622,1616,1617,1623],"class_list":["post-3871","post","type-post","status-publish","format-standard","hentry","category-anleitung","category-linux-2","category-raspberry-pi","category-tools","tag-escape","tag-escaped","tag-messer","tag-xml","tag-xml-bearbeiten","tag-xml-escapen","tag-xmlstar","tag-xmlstarlet","tag-xmlstarlet-1-6-0"],"_links":{"self":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/3871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3871"}],"version-history":[{"count":0,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/3871\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3871"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}