shell,unix,bpel,xmlstarlet,xmllint
Using xmlstarlet : $ cat bpel.xml <?xml version="1.0"?> <ns:ItemList xmlns:ns="http:///blabla"> <GenericItem> <ns2:LocalItem xmlns:ns2="http:///blabla"> <ItemSource> </ItemSource> <ConcItemSource> <name></name> <requirements/> <strategy/> </ConcItemSource> <dataFormat/> <directory>d1</directory> <file/> </ns2:LocalItem> </GenericItem> <GenericItem> <ns2:LocalItem xmlns:ns2="http:///blabla">...
Both of the following seem to avoid insertion of <?xml version="1.0"?>: xmllint --exc-c14n data.xml xmllint --c14n data.xml Hint: xmllint --help -or- man xmllint...
This text node you are after is indeed a following sibling, but it's a text node, not an element node. An expression like following-sibling::* Only looks for following siblings that are elements. To match text nodes, use text(): $ curl -s http://lists.opencsw.org/pipermail/users/2015-January/date.html | xmllint --html --xpath '/html/body/p/b[contains(., "Messages:")]/following-sibling::text()' The commands...
strip the namespace with sed given in pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> </project> this: cat pom.xml | sed '2 s/xmlns=".*"//g' | xmllint --xpath '/project/modelVersion' - returns this: <modelVersion>4.0.0</modelVersion> if you have funky...
Perhaps it would suffice to simply select all attributes of the host element? $ xmllint example.xml --xpath "//hosts/host[starts-with(@name,"blah")]/@*" > out.txt $ cat out.txt name="blah001" serial="ABC001" name="blah002" serial="ABC002" If that's not enough - if the output should be structured in a certain way, I'd recommend you write a simple XSLT transformation...
You are probably aware that your input XML is in a default namespace. Your original XPath expression: xmllint --xpath '//feed/entry/title' myfile.xml will never succeed to find elements that are in a namespace. That's why the XPath result set is empty. If you're absolutely unwilling to register or declare a namespace,...
The command is almost right, you only have to fix the XPATH expression: xmllint --xpath '//service[@name="GETME"]' Sample.xml \ no slash hare However, you have to check whether your xmllint actually supports XPATHs: $ xmllint --version xmllint: using libxml version 20902 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1...
If I modify only one line of your input file, changing <png></png> to <png>Some text goes here</png> ...then your code works perfectly as already written. Thus, the error has nothing at all to do with the first few descriptions having no png. Mind you, since you don't have any namespaces...
As far as I know, xmllint is not made for editing XML files, so you can't do that. One possible solution to your problem is command: grep -v your_pattern your_file > new_file It will choose all other lines than the one and copy it into a new file. Another, probably...
The xpath query //resource/file/@href will give you the list of hrefs. But there will be duplicates based on that xml sample. If you just want the list from the first resource you could use //resource[1]/file/@href or specify by the identifier as //resource[@identifier="group0_pages"]/file/@href. However, for some reason I was unable to...
You can try using this xpath : /all/item[readonly='true']/name Your initial xpath also looks good given the XML posted in question as input, only you may need to change double quotes with single quotes in the xpath parameter value : --xpath "all/item[readonly/text() = 'true']/name" ...
Basically, you can use xpath predicate ([]) to filter element. Assume that your XML doesn't have namespace prefix involved, the following xpath will get hostname attribute from <node> element having descendant element <database>: //node[elements/database]/@hostname Since your actual XML has prefix involved you need to declare namespace prefix first, probably using...
Your problem, in a nutshell, is that awk keeps using the same pipe. The pipe is remembered under the exact same string with which it was opened (which means that you cannot run the exact same command twice at the same time), and records are written into it one after...
xmllint is probably printing to stderr instead of stdout. Redirect your stderr to stdout before the grep. xmllint --noout --schema MySchema.xsd dir/*.xml 2>&1 | grep -v "validates ...
Try this command: xmllint --xpath '//thing[foo="abc"]/bar/text()' test.xml Another command: echo 'cat //thing[foo="abc"]/bar/text()' | xmllint --shell test.xml Also try xmlstarlet: xmlstarlet sel -t -m '//thing[foo="abc"]/bar' -v 'text()' test.xml ...
First of all, external DTDs do not need the <!DOCTYPE preamble - remove it from the DTD file: <!ELEMENT coord (date)> <!ELEMENT date (#PCDATA)> Then, --loaddtd fetches an external DTD, which is not the same as validating against an external DTD. Use the --dtdvalid option as follows: $ xmllint --noout...
You don't need a space there. Xmllint probably wants you to put the encoding attribute next which would be separated by a space, which would be good form, but also not strictly necessary.