Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to manipulate XML data with XMLStarlet for translation purposes as asked in Translate text nodes of GraphML XML (CAS)? but although the nodes I am trying to read are returned, there is whitespace/newlines returned. Sample XML can be found in the other question and the program call is as follows:

xml sel --noblanks --text --template --nl --value-of "//y:NodeLabel" --value-of "//y:EdgeLabel" my.graphml

resulting in

...
The node's text
...
          The edge's text
...

(... represents a blank line)

I would like an explanation of what is happening and whether the result is to be expected or if this is caused by XMLStarlet. A fixed program call would be appreciated, but of course alternative programs or - if neccessary - filtering the blank lines would be acceptable as well (grep/sed/awk, CMD).

share|improve this question

2 Answers 2

I still don't know but I solved the task with Python and lxml, which does not capture whitespace in a node's text member.

share|improve this answer
xmlstarlet sel -T -t -v "//node/item" file.xml

and it outputs the content of

<node><item>content</item></node>

as text without additional whitespace.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.