0

I tried

var = $(xmllint --xpath 'string(//datatype)' dataReport_2.xml)

which seems not to work.

It only stores a string value of this whole command into a variable. Is there any way to store this value into a variable?

Vlastimil Burián
  • 3,024
  • 2
  • 31
  • 52
buzzmind
  • 109
  • 2
  • 10
  • First, please read [how to ask good questions](https://stackoverflow.com/help/mcve). Second, try the command without string() first because may not have a text node. – LMC Jan 26 '18 at 20:43
  • Luis Muñoz Hi, I basically try with or without the parentheses which still does not work. Yes, this xml does contain this text node. – buzzmind Jan 26 '18 at 20:46
  • 4
    In `sh`, you can't put spaces around `=` in an assignment. – choroba Jan 26 '18 at 20:48
  • edit you question, add errors if any, add more detail to your code. Again, read the link in my previous comment please. – LMC Jan 26 '18 at 20:51
  • 1
    Please prefer asking one question per post. StackOverflow works better that way (for example, if you ask two separate questions in one post, you can't accept two answers) – that other guy Jan 26 '18 at 21:34
  • that other guy yeah, I will open another post, thanks – buzzmind Jan 26 '18 at 23:40

1 Answers1

1

You can't put spaces or any kind of white-space characters around =, so try this:

var=$(xmllint --xpath 'string(//datatype)' dataReport_2.xml)
Vlastimil Burián
  • 3,024
  • 2
  • 31
  • 52