[xml] xmlParseFile and stdin



Hello,

I feel rather stupid not being able to figure this one out myself, but I sure hope someone can help me. I'm trying to read from an input-file, which is provided as a parameter, using xmlParseFile. However, if no parameter is supplied, stdin should be used.

So I came up with this code:

   char *SpecStream;
   if ( argc-optind < 1 ){
     SpecStream = "stdin";
   } else {
     if ( (SpecStream = argv[optind]) == NULL ){
        perror(NAME);
        return 1;
     }
   }

   xmlDocPtr doc = xmlParseFile(SpecStream);
   if(!doc) {
     gsErrorMsg("Document not parsed succesfully. \n");
     return 1;
   }

However, if no parameter is supplied, it tries to read from a file named stdin! Since xmlParseFile needs a char *, can it be used to read from stdin? If so, how? If not, what funtion should I use?

Thanks a lot!
Johfra





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]