int
main (int argc, char** argv)
{
xml_g_set_prgname(argv[0]);
if (argc < 3)
{
g_printerr ("> %s filename xpath [options]\n"
"\t cut away the markup referenced under the given\n"
"\t xpath (abbreviated notation). That's largely\n"
"\t to reverse the operation of an xml-add-markup.\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);
int err = 0;
if (! node)
g_error ("node not found: %s\n", xpath);
if (! node->parent)
g_error ("can not cut the root: %s\n", xpath);
node = xml_node_group_cut (node);
if (! node)
g_error ("the node was not cut: %s\n", xpath);
___ GString* dump = xml_tree_node_to_xml (tree, 0);
if (! dump || ! dump->str)
g_error ("could not dump tree from internals");
xml_g_string_to_file (dump, 0);
g_string_free (dump, 1);
return err;
____;____;____;____;
} |
|