Menu
  • HOME
  • TAGS

how can a BPEL variable be put into a shell variable

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">...

xmllint: Remove

xmllint

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...

How to select the text behind an element?

bash,xpath,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...

Force xmllint to ignore bad defult xmlns

xmllint

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...

Fetching multiple values using xmllint

xml,xpath,xmllint

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...

xmllint and xpath to parse xml data from https://mail.google.com/mail/feed/atom

xml,xpath,xmlns,xmllint

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,...

How to grep an xml block in an xml file using a keyword

xml,shell,unix,xpath,xmllint

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...

xmllint match and extract value

xml,xpath,xmllint

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...

Removing a line from XML file using xmllint in shell script

xml,bash,shell,xmllint

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...

Bash rename files based on XML

xml,bash,xml-parsing,xmllint

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...

How to select all nodes using xmllint where node on same level has certain value?

xpath,xmllint

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" ...

xmllint give attribute only if elements are present unix

xml,unix,xpath,filter,xmllint

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...

Indent XML-like file with awk and xmllint

xml,bash,awk,format,xmllint

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...

How do I pipe grep xmllint results?

linux,grep,pipe,xmllint

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 ...

Get child value if another child value matches

xml,xpath,xmllint

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 ...

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

xml,file,local,dtd,xmllint

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...

xmllint warns about missing space of xslt generated file

xml,xslt,xmllint,libxslt

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.