Last active
April 16, 2018 02:54
-
-
Save slayerlab/96e7ea91ade066aaba816af11fcec799 to your computer and use it in GitHub Desktop.
NodeChecker -- { pick Element names }; // fixing wierd syntaxes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* vim: set et sw=2 ts=2 : */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <libxml/parser.h> | |
#include <libxml/tree.h> | |
__attribute__ ((noinline, noreturn)) | |
void print_usage(const char *); | |
static void PrintElementNames(xmlNode *node) | |
{ | |
xmlNode *cur_node; | |
for (cur_node = node; cur_node; | |
cur_node = cur_node->next) { | |
if (XML_ELEMENT_NODE != cur_node->type) { | |
fprintf(stdout, "node type: Element, name: %s\n", cur_node->name); | |
} | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
xmlDoc *doc; | |
xmlNode *GetElementByDoc; | |
if (argc != 2) { | |
print_usage(argv[0]); | |
exit(EXIT_FAILURE); | |
} | |
LIBXML_TEST_VERSION /* Macro to check API for match with | |
the DLL we are using */ | |
/* file parser ;; get the DOM */ | |
if (!(doc = xmlReadFile(argv[1], 0, 0))) { | |
printf("[!] Error: could not parse file \'%s\'.\n", argv[1]); | |
exit(EXIT_FAILURE); | |
} | |
GetElementByDoc = xmlDocGetRootElement(doc); | |
PrintElementNames(GetElementByDoc); | |
xmlFreeDoc(doc); // free(document) | |
xmlCleanupParser(); // free(_globals) | |
exit(EXIT_SUCCESS); | |
} | |
void print_usage(const char *argv0) | |
{ | |
fprintf(stderr, | |
"[!] Usage: %s <file.xml>\n", argv0); | |
exit(EXIT_FAILURE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dropping this as public 2 years later.