xmllint

xmllint failing to properly query with xpath

為{幸葍}努か 提交于 2019-12-11 20:19:58
问题 I'm trying to query an xml file generated by adium. xmlwf says that it's well formed. By using xmllint's debug option i get the following: $ xmllint --debug doc.xml DOCUMENT version=1.0 encoding=UTF-8 URL=doc.xml standalone=true ELEMENT chat default namespace href=http://purl.org/net/ulf/ns/0.4-02 ATTRIBUTE account TEXT content=foo@bar.com ATTRIBUTE service TEXT compact content=MSN TEXT compact content= ELEMENT event ATTRIBUTE type Everything seems to parse just fine. However, when I try to

xmllint isn't working in windows command prompt

最后都变了- 提交于 2019-12-08 08:37:06
问题 I've tried to check xml-file on validness with cmd.exe by using the command 'xmllint' as in the example: xmllint -schema Bookstore.xsd --noout Bookstore-XSD.xml but as a result, I saw the error: 'xmllint' is not recognized as an internal or external command, operable program or batch file. Should I install some specific library? And if I should, where is it must be (what is the folder)? 回答1: xmllint isn't a standard part of Windows. It's typically used on a Unix-based operating system. You

Format all XML files in a directory and save them in a subdirectory

做~自己de王妃 提交于 2019-12-08 01:50:33
问题 I'm trying to write a script that will look through a directory, find all the XML files, run them through xmllint , and save the formatted results to a file of the same name in a subdirectory called formatted . Here's the script I have so far: find . -maxdepth 1 -type f -iname "*.xml" | xargs -I '{}' xmllint --format '{}' > formatted/'{}' This works, to an extent. The subdirectory ends up with one file, named "{}" , which is just the results of the final file that was processed through

select an xml element, ignore element name, print newline

人走茶凉 提交于 2019-12-07 15:32:39
问题 I'd like to select the first element, but ignore its name in the output. This is what I'm getting, after requesting the first url element from each input xml file: % xmllint \ --xpath '(//yandexsearch/response/results/grouping/group/doc/url)[1]' \ *.response.ya.xml <url>https://example.com/</url><url>https://example.net/</url><url>https://example.org/</url> But this is what I want instead: https://example.com/ https://example.net/ https://example.org/ Note that the idea is to select the value

How do I install the latest build of xmllint on OSX 10.7.5

↘锁芯ラ 提交于 2019-12-07 01:14:03
问题 The problem is that I am trying to validate an xml file using xmllint. On my machine (OSX 10f.7.5) it says the xml is invalid. When a co-worker tries it on his machine, it says it is valid. I am not sure what version of OSX he is running but I do know that my version of xmllint is $ xmllint --version xmllint: using libxml version 20703 and his version is $ xmllint --version xmllint: using libxml version 20708 So the question is how do I build that version (or the latest version) on my machine

Extract value from xml file with namespaces by using xmllint in bash

不问归期 提交于 2019-12-06 11:57:01
I need to extract the name value (Product Finder) from this xml: File: config.xml <?xml version="1.0" encoding="utf-8"?> <widget id="com.abc.app" version="1.3.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0" ios-CFBundleVersion="1.3.1.5" android-versionCode="5"> <name>Product Finder</name> <description> Description </description> </widget> I've tried: mles$ xmllint --xpath "/widget/name/text()" config.xml XPath set is empty Which is probably because my config.xml file has other namespaces. According

Add an attribute using xmllint

让人想犯罪 __ 提交于 2019-12-05 06:21:28
I want to add an attribute to the tag, using xmllint . Can I do this is through xmllint? Xmllint in not made to edit XML, so I think the answer is “no, you can't”. To edit XML, you can use XMLStarlet, the syntax to add an attribute into existing XML document is: xmlstarlet ed -L -i xpath -t attr -n name -v value file 来源: https://stackoverflow.com/questions/6404277/add-an-attribute-using-xmllint

How do I install the latest build of xmllint on OSX 10.7.5

北城以北 提交于 2019-12-05 04:52:02
The problem is that I am trying to validate an xml file using xmllint. On my machine (OSX 10f.7.5) it says the xml is invalid. When a co-worker tries it on his machine, it says it is valid. I am not sure what version of OSX he is running but I do know that my version of xmllint is $ xmllint --version xmllint: using libxml version 20703 and his version is $ xmllint --version xmllint: using libxml version 20708 So the question is how do I build that version (or the latest version) on my machine? It seems that the xmlstarlet package contains xmllint, so this should do the trick: brew install

How to do command line XPath queries in huge XML files?

元气小坏坏 提交于 2019-12-04 18:49:34
问题 I have a collection of XML files, and some of them are pretty big (up to ~50 million element nodes). I am using xmllint for validating those files, which works pretty nicely even for the huge ones thanks to the streaming API. xmllint --loaddtd --stream --valid /path/to/huge.xml I recently learned that xmllint is also capable of doing command line XPath queries, which is very handy. xmllint --loaddtd --xpath '/root/a/b/c/text()' /path/to/small.xml However, these XPath queries do not work for

Using xmllint and xpath with a less-than-perfect HTML document?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 10:50:49
问题 I have an HTML page that is generated by an existing tool - I cannot change the output of this tool. However, I want to use xmllint with the --xpath option to pick out a few specific pieces of information from the downloaded webpage. The problem is that the page starts with: <html lang=en><head>... And xmllint throws errors nearly immediately: html.out:2: parser error : AttValue: " or ' expected <html lang=en><head> ^ The issue certainly seems to be the missing enclosing quotation marks