views:

32

answers:

1

Hello,

I would like to know the best way to parse a large amount of xml from stdin (data getting piped) into a program I am writing using libxml2. I can parse fine using a reader from the function xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename) when I have a char * to the name of the file. I would preferably like to wind up with a reader so the rest of my program remains the same.

Thank you.

A: 

I believe the best thing to do is to use the opening function that contains a file descriptor as the parameter and pass STDIN_FILENO.

http://www.xmlsoft.org/html/libxml-xmlreader.html#xmlReaderNewFd

Ryan
`stdin` isn't a file descriptor (`int`), it's a file pointer (`FILE *`). You want `STDIN_FILENO` to pass to `xmlReaderForFd()`.
caf
whoops - thanks!
Ryan