Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, How can I pass xml data from memory or a variable to xmllint that expects a file as input? Or does xmllint have the capabilities to read from stin ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    4

    Passing xml in mem or variable to xmllint

    Hello,

    How can I pass xml data from memory or a variable to xmllint that expects a file as input?

    Or does xmllint have the capabilities to read from stin or a variable?

    Thanks in advance

    LA

  2. #2
    Just Joined!
    Join Date
    Jul 2010
    Posts
    4
    I came up with ( watch the - after xmllint )


    Code:
    #!/bin/sh
    echo "<?xml version='1.0' encoding='UTF-8'?>
    <insertion>
    	<mytag>123456</mytag>
    	<mytag2>789</mytag2>
    </insertion>" | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'
    but I want to use the --shell argument in xmllint

    So can I use something like

    Code:
    echo cat  /begin_mytag/end_mytag |  xmllint -shell - | sed -ne 's/<[^>]\{1,\}>//gp'
    and still add info to stdin of xmllint?

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    4
    Maybe is my question unclear or should I post it in a different forum?

    Any advise?

  4. #4
    Just Joined!
    Join Date
    Jul 2010
    Location
    Kolkata
    Posts
    3
    Hi,

    Obviously you can do something like below in command prompt:

    cat <file_name> | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'

    for examlple:
    cat test.xml | xmllint - | sed -ne 's/<[^>]\{1,\}>//gp'

    But I am confused why do you want to use --shell option

    Please let me know if you have any questions.

  5. #5
    Just Joined!
    Join Date
    Jul 2010
    Posts
    4
    Thanks for your time.

    The problem is I need both, with --shell/cat I supply the filter and with - I supply the xml .

    I need the combination of 'XML in memory or variable' passed to xmllint with the - option and the filter via the --shell option.

    The filter is 'cat /begin_mytag/end_mytag'
    and the xml value is in a variable
    "<?xml version='1.0' encoding='UTF-8'?>
    <insertion>
    <mytag>123456</mytag>
    <mytag2>789</mytag2>
    </insertion>"

    So far as I my knowledge goes, I don't know how to use both.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...