int
main (int argc, char** argv)
{
xml_g_set_prgname(argv[0]);
if (argc < 3)
{
g_printerr ("> %s filename xpath [options]\n"
"\t print the xml part within the node referenced \n"
"\t by the given xpath position (abbreviated forms)\n",
g_get_prgname());
return 1;
} |
___ gchar *filename = 0;
const gchar *xpath = 0, *styleflag = "";
{ int i ; for (i=1; i < argc ; i++) {
if (argv[i][0] == '-') { styleflag = argv[i]; continue; } |
if (! filename) { filename = argv[i]; continue; } |
if (! xpath) { xpath = argv[i]; continue; } |
g_warning ("extra argument on commandline, ignored: %s", argv[i]);
} | } |
___ xml_GNode* tree; GError* error = 0;
tree = xml_g_markup_parse_file (0, filename, &error);
if (error)
xml_g_show_error (&error, "after parsing file:\n\t'%s'", filename);
___ xml_GNode* node = xml_path_node (tree, xpath);
if (! node)
g_error ("node not found: %s\n", xpath);
___ int style = 0;
if (strstr (styleflag, "-text")) style = 1;
___ GString* dump = xml_tree_dump_node_append (0, node);
if (! dump)
g_error ("node tree could not be converted back to xml (bug!)\n");
xml_g_string_to_file (dump, 0);
g_string_free (dump, TRUE);
return 0;
____;____;____;____;____;
} |
|