i am writing a c++ function that will parse .xml file.
i Used system(“grep”); type system call to use linux command. now my problem is that i want to select more than one line in given tag. ex.
content of .xml file
====================
<state>
<text> hi this is first li </text>
<sec> dsfn sdlkf sfd </sec>
</state>
===================
i want to print all content between and tag. which and how i can use linux commands.
plz help me….thanks i advance.
exec, execve or system calls: demo
Proceed to
fopenoutput (or std::fstream reader(“output”) if you fancy). Note that system is quickly a security hole, so you shouldn’t use it in critical apps (like daemons).Using exec you could redirect. So you could perhaps open a pipe() from your program, fork(), in the child assign the stdout filedescriptor to the pipe() (see dup2 call) and
execin the child.The parent process can then read the output from the pipe without need for a temp file.
All of this should be on a zillion tutorials, which I don’t have to the time to google for you right now.
May I suggest using perl or shell script. If you post an actual example I could show you the code in both shell and c/c++
Update here is how to do it with XSLT
textonly.xslt:
output demo: