Questions tagged [xmllint]

xmllint is a command line XML parser which provides syntax validation, gzip compression, and formatting options.

xmllint is a command line tool that is part of libxml2 which is a C Parser and toolkit that runs on multiple platforms. Download links for libxml2 can be found at http://xmlsoft.org/downloads.html

344 questions
65
votes
3 answers

xmllint failing to properly query with xpath without namespaces

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 …
ailnlv
  • 1,779
  • 1
  • 15
  • 29
62
votes
1 answer

how to Validate a XML file with XSD through xmllint

i have to validate my xml file with a given XSD file. Figured the easiest way to do so would be xmllint, but i can't get it to work. Can anyone tell me the exact command? I tried: xmllint --valid myxsd.xsd myxml.xml What am i doing wrong? This…
Econ
  • 2,419
  • 3
  • 13
  • 18
61
votes
3 answers

No matching global declaration available for the validation root

Background Validate an XML document using a schema. Problem The simplest form of the problem is shown in two files. XML Document file.xml sugar…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
52
votes
1 answer

How to get Xmllint to read from stdin?

I don't want to create an XML file I need to use the --shell with cat to create filters I don't have xpath in my version of xmllint, using libxml2-2.7.6-14.el6.x86_64 xml|xmllint --shell - <<< $(echo 'cat /') -:1: parser error : Start tag expected,…
Ura
  • 2,173
  • 3
  • 24
  • 41
51
votes
7 answers

Installing xmllint

I needed help installing xmllint from this website: http://xmlsoft.org/sources/win32/ In particular, I am not sure which file I am supposed to download - when I click the link for precompiled Windows binaries I am brought to a list of several files…
sgx
  • 1,265
  • 3
  • 19
  • 36
38
votes
2 answers

curl and xmllint pipe

I try to pipe curl and xmllint to parse the xml output from an url. But for some reason xml won't parse the xml and instead the resulting xml from the curl is shown. I'm a missing a setting? If is store the result of the curl action as a file and…
Thomas
  • 523
  • 1
  • 5
  • 14
31
votes
6 answers

Native shell command set to extract node value from XML

I'm trying to extract the value of a node from a pom.xml: org.me.labs my-random-project 1.5.0
Karthik V
  • 1,033
  • 1
  • 14
  • 29
25
votes
4 answers

Linux Bash XMLLINT with XPATH

Today I get to learn how to use xmllint properly. It does not seem to be well covered or explained. I plan to use a single language resource file to run my entire system. I have a mixture of bash scripts and php pages that must read from this…
RootWannaBe
  • 363
  • 1
  • 3
  • 7
24
votes
1 answer

xmllint : how to validate an XML using a local DTD file

I have a local DTD file test.dtd. Content is : ]> I'd like to validate an XML using xmllint. This XML has no DOCTYPE in it :
Eric H.
  • 2,152
  • 4
  • 22
  • 34
23
votes
4 answers

xmllint unknown option '--xpath'

I've seen this syntax several places (eg, here): xmllint --xpath '/plist/array/string/text()' tmp.xml, used to query a particular XML node using an xpath selector. However, I'm getting the error Unknown option --xpath when I try to execute this on…
Neal Pisenti
  • 526
  • 1
  • 3
  • 7
22
votes
3 answers

xmllint : validate an XML file against two XSD schemas (envelope / payload)

I am using xmllint to do some validations and I have an XML instance document which needs to validate against two schemas: one for the outer "envelope" (which includes an any element) and one for the particular payload. Say A.xsd is the envelope…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
20
votes
2 answers

How to use xmllint to validate an XML document with an XSD?

I'm trying to use xmllint to check my work while developing a basic XSD i.e. XML Schema schema. However it's giving me an error Validation failed: no DTD found. What am I doing wrong? My xmllint command: xmllint --noout --valid --schema simple.xsd…
Tristan
  • 1,730
  • 3
  • 20
  • 25
17
votes
5 answers

How to append a newline after every match using xmlint --xpath

I have the following HTML code: I would like to parse it to receive such…
Adam Siemion
  • 15,569
  • 7
  • 58
  • 92
16
votes
4 answers

How to verify whether a xml file is valid in sh or bash?

How to verify whether a XML file is valid in sh (preferably) or bash? I have a file that often get corrupted and needs to be replaced while I take my time to investigate the underlying issue. Is there any easy way of performing this task with sh or…
user2799603
  • 873
  • 3
  • 13
  • 19
16
votes
3 answers

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

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…
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
1
2 3
22 23