本文整理汇总了C++中xmlNewTextChild函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlNewTextChild函数的具体用法?C++ xmlNewTextChild怎么用?C++ xmlNewTextChild使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlNewTextChild函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bg_nle_media_list_save
void
bg_nle_media_list_save(bg_nle_media_list_t * list, xmlNodePtr node)
{
char * tmp_string;
int i;
xmlNodePtr child;
xmlNodePtr grandchild;
if(list->open_path)
{
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)open_path_name, NULL);
xmlAddChild(child, BG_XML_NEW_TEXT(list->open_path));
}
if(list->num_files)
{
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)files_name, NULL);
tmp_string = bg_sprintf("%d", list->num_files);
BG_XML_SET_PROP(child, "num", tmp_string);
free(tmp_string);
for(i = 0; i < list->num_files; i++)
{
grandchild = xmlNewTextChild(child, (xmlNsPtr)0,
(xmlChar*)file_name, NULL);
bg_nle_file_save(grandchild, list->files[i]);
}
}
}
示例2: save_audio_stream
static void save_audio_stream(xmlNodePtr node,
bg_nle_audio_stream_t * s)
{
xmlNodePtr child;
char * tmp_string;
/* Timescale */
tmp_string = bg_sprintf("%d", s->timescale);
BG_XML_SET_PROP(node, "scale", tmp_string);
free(tmp_string);
/* Offset */
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)start_time_name, NULL);
tmp_string = bg_sprintf("%"PRId64, s->start_time);
xmlAddChild(child, BG_XML_NEW_TEXT(tmp_string));
free(tmp_string);
/* Duration */
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)duration_name, NULL);
tmp_string = bg_sprintf("%"PRId64, s->duration);
xmlAddChild(child, BG_XML_NEW_TEXT(tmp_string));
free(tmp_string);
}
示例3: save_video_stream
static void save_video_stream(xmlNodePtr node,
bg_nle_video_stream_t * s)
{
char * tmp_string;
xmlNodePtr child;
/* Timescale */
tmp_string = bg_sprintf("%d", s->timescale);
BG_XML_SET_PROP(node, "scale", tmp_string);
free(tmp_string);
if(s->tc_format.int_framerate)
{
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)tc_rate_name, NULL);
tmp_string = bg_sprintf("%d", s->tc_format.int_framerate);
xmlAddChild(child, BG_XML_NEW_TEXT(tmp_string));
free(tmp_string);
}
if(s->tc_format.flags)
{
child = xmlNewTextChild(node, (xmlNsPtr)0,
(xmlChar*)tc_flags_name, NULL);
tmp_string = bg_sprintf("%d", s->tc_format.flags);
xmlAddChild(child, BG_XML_NEW_TEXT(tmp_string));
free(tmp_string);
}
}
示例4: main
int main (int argc, char **argv)
{
xmlDocPtr pdoc = NULL;
xmlNodePtr proot_node = NULL,pnode = NULL,pnode1 = NULL;
// 创建一个新文档并设置 root 节点
// 一个 XML 文件只有一个 root 节点
pdoc = xmlNewDoc (BAD_CAST "1.0");
proot_node = xmlNewNode (NULL, BAD_CAST "根节点");
xmlNewProp (proot_node, BAD_CAST "版本", BAD_CAST "1.0");
xmlDocSetRootElement (pdoc, proot_node);
pnode = xmlNewNode (NULL, BAD_CAST "子节点1");
// 创建上面 pnode 的子节点
xmlNewChild (pnode, NULL, BAD_CAST "子子节点1", BAD_CAST "信息");
// 添加子节点到 root 节点
xmlAddChild (proot_node, pnode);
pnode1 = xmlNewNode (NULL, BAD_CAST "子子节点1");
xmlAddChild (pnode, pnode1);
xmlAddChild (pnode1,xmlNewText (BAD_CAST "这是更低的节点,子子子节点1"));
// 还可以这样直接创建一个子节点到 root 节点上
xmlNewTextChild (proot_node, NULL, BAD_CAST "子节点2", BAD_CAST "子节点2的内容");
xmlNewTextChild (proot_node, NULL, BAD_CAST "子节点3", BAD_CAST "子节点3的内容");
// 保存 xml 为文件,如果没有给出文件名参数,就输出到标准输出
xmlSaveFormatFileEnc (argc > 1 ? argv[1]:"-", pdoc, "UTF-8", 1);
// 释放资源
xmlFreeDoc (pdoc);
xmlCleanupParser ();
xmlMemoryDump ();
return 0;
}
示例5: xml_subprocess_output
static void
xml_subprocess_output(pcmk__output_t *out, int exit_status,
const char *proc_stdout, const char *proc_stderr) {
xmlNodePtr node, child_node;
char *rc_as_str = NULL;
xml_private_t *priv = out->priv;
CRM_ASSERT(priv != NULL);
rc_as_str = crm_itoa(exit_status);
node = xmlNewNode(g_queue_peek_tail(priv->parent_q), (pcmkXmlStr) "command");
xmlSetProp(node, (pcmkXmlStr) "code", (pcmkXmlStr) rc_as_str);
if (proc_stdout != NULL) {
child_node = xmlNewTextChild(node, NULL, (pcmkXmlStr) "output",
(pcmkXmlStr) proc_stdout);
xmlSetProp(child_node, (pcmkXmlStr) "source", (pcmkXmlStr) "stdout");
}
if (proc_stderr != NULL) {
child_node = xmlNewTextChild(node, NULL, (pcmkXmlStr) "output",
(pcmkXmlStr) proc_stderr);
xmlSetProp(node, (pcmkXmlStr) "source", (pcmkXmlStr) "stderr");
}
pcmk__xml_add_node(out, node);
free(rc_as_str);
}
示例6: save_languages_to_xml
void save_languages_to_xml (language * languages, int size)
{
xmlDocPtr doc;
xmlNodePtr parent, child;
xmlXPathContextPtr xpathCtx;
xmlXPathObjectPtr xpathObj;
int i;
xmlKeepBlanksDefault(0);
doc = xmlNewDoc (BAD_CAST "1.0");
parent = xmlNewNode(NULL, "languages");
xmlDocSetRootElement(doc, parent);
for(i=0; i<size; i++)
{
child = xmlNewTextChild (parent, NULL, "lang", NULL);
xmlNewTextChild (child, NULL, "name", languages->name);
xmlNewTextChild (child, NULL, "code", languages->code);
xmlNewTextChild (child, NULL, "flag", languages->flag);
languages++;
}
xmlSaveFormatFile ("src/config/languages.xml", doc, 1);
xmlFreeDoc(doc);
}
示例7: battmon_write_config
static void
battmon_write_config(Control *ctrl, xmlNodePtr parent)
{
xmlNodePtr root;
char value[MAXSTRLEN + 1];
t_battmon *battmon = (t_battmon *) ctrl->data;
root = xmlNewTextChild(parent, NULL, "BatteryMonitor", NULL);
/* Display Percentage */
g_snprintf(value, 2, "%d", battmon->options.display_percentage);
xmlSetProp(root, "display_percentage", value);
/* Display Percentage in Tooltip */
g_snprintf(value, 2, "%d", battmon->options.tooltip_display_percentage);
xmlSetProp(root, "tooltip_display_percentage", value);
/* Display Time in Tooltip */
g_snprintf(value, 2, "%d", battmon->options.tooltip_display_time);
xmlSetProp(root, "tooltip_display_time", value);
/* Low Percentage */
g_snprintf(value, 4, "%d", battmon->options.low_percentage);
xmlSetProp(root, "low_percentage", value);
/* Critical Percentage */
g_snprintf(value, 4, "%d", battmon->options.critical_percentage);
xmlSetProp(root, "critical_percentage", value);
/* Action on Low */
g_snprintf(value, 2, "%d", battmon->options.action_on_low);
xmlSetProp(root, "action_on_low", value);
/* Action on Critical */
g_snprintf(value, 2, "%d", battmon->options.action_on_critical);
xmlSetProp(root, "action_on_critical", value);
/* Command on Low */
xmlNewTextChild(root, NULL, "command_on_low", battmon->options.command_on_low);
/* Command on Critical */
xmlNewTextChild(root, NULL, "command_on_critical", battmon->options.command_on_critical);
}
示例8: playlist_render_xspf
xmlNodePtr playlist_render_xspf(playlist_t *playlist)
{
xmlNodePtr rootnode, tracklist, tracknode;
playlist_track_t *track;
if (!playlist)
return NULL;
rootnode = xmlNewNode(NULL, XMLSTR("playlist"));
xmlSetProp(rootnode, XMLSTR("version"), XMLSTR("1"));
xmlSetProp(rootnode, XMLSTR("xmlns"), XMLSTR("http://xspf.org/ns/0/"));
tracklist = xmlNewNode(NULL, XMLSTR("trackList"));
xmlAddChild(rootnode, tracklist);
track = playlist->first;
while (track) {
tracknode = xmlNewNode(NULL, XMLSTR("track"));
xmlAddChild(tracklist, tracknode);
/* TODO: Handle meta data */
if (track->title)
xmlNewTextChild(tracknode, NULL, XMLSTR("title"), XMLSTR(track->title));
if (track->creator)
xmlNewTextChild(tracknode, NULL, XMLSTR("creator"), XMLSTR(track->creator));
if (track->album)
xmlNewTextChild(tracknode, NULL, XMLSTR("album"), XMLSTR(track->album));
if (track->trackNum)
xmlNewTextChild(tracknode, NULL, XMLSTR("trackNum"), XMLSTR(track->trackNum));
track = track->next;
}
return rootnode;
}
示例9: monitor_write_config
static void monitor_write_config(Control *ctrl, xmlNodePtr parent)
{
xmlNodePtr root;
char value[20];
t_global_monitor *global;
global = (t_global_monitor *)ctrl->data;
root = xmlNewTextChild(parent, NULL, MONITOR_ROOT, NULL);
g_snprintf(value, 2, "%d", global->monitor->options.use_label);
xmlSetProp(root, "Use_Label", value);
g_snprintf(value, 8, "#%02X%02X%02X",
(guint)global->monitor->options.color[IN].red >> 8,
(guint)global->monitor->options.color[IN].green >> 8,
(guint)global->monitor->options.color[IN].blue >> 8);
xmlSetProp(root, "Color_In", value);
g_snprintf(value, 8, "#%02X%02X%02X",
(guint)global->monitor->options.color[OUT].red >> 8,
(guint)global->monitor->options.color[OUT].green >> 8,
(guint)global->monitor->options.color[OUT].blue >> 8);
xmlSetProp(root, "Color_Out", value);
if (global->monitor->options.label_text)
{
xmlSetProp(root, "Text",
global->monitor->options.label_text);
}
else
{
xmlSetProp(root, "Text", DEFAULT_TEXT);
}
if (global->monitor->options.network_device)
{
xmlSetProp(root, "Network_Device", global->monitor->options.network_device);
}
else
{
xmlSetProp(root, "Network_Device", DEFAULT_DEVICE);
}
g_snprintf(value, 20, "%lu", global->monitor->options.max[IN]);
xmlSetProp(root, "Max_In", value);
g_snprintf(value, 20, "%lu", global->monitor->options.max[OUT]);
xmlSetProp(root, "Max_Out", value);
g_snprintf(value, 2, "%d", global->monitor->options.auto_max);
xmlSetProp(root, "Auto_Max", value);
g_snprintf(value, 20, "%d", global->monitor->options.update_interval);
xmlSetProp(root, "Update_Interval", value);
root = xmlNewTextChild(parent, NULL, MONITOR_ROOT, NULL);
}
示例10: bg_upnp_device_description_add_icon
void bg_upnp_device_description_add_icon(xmlDocPtr ptr,
const char * mimetype,
int width, int height, int depth, const char * url)
{
char * tmp_string;
xmlNodePtr iconlist;
xmlNodePtr icon;
xmlNodePtr node = get_device_node(ptr);
iconlist = bg_xml_find_node_child(node, "iconList");
if(!iconlist)
iconlist = xmlNewTextChild(node, NULL, (xmlChar*)"iconList", NULL);
icon = xmlNewTextChild(iconlist, NULL, (xmlChar*)"icon", NULL);
bg_xml_append_child_node(icon, "mimetype", mimetype);
tmp_string = bg_sprintf("%d", width);
bg_xml_append_child_node(icon, "width", tmp_string);
free(tmp_string);
tmp_string = bg_sprintf("%d", height);
bg_xml_append_child_node(icon, "height", tmp_string);
free(tmp_string);
tmp_string = bg_sprintf("%d", depth);
bg_xml_append_child_node(icon, "depth", tmp_string);
free(tmp_string);
bg_xml_append_child_node(icon, "url", url);
}
示例11: add_group
static xmlNodePtr
add_group (GPInstructLessonElementGroup *group,
xmlNodePtr parent_node)
{
GPInstructLessonElement *curr_lesson_element;
GList *lesson_elements;
GList *curr_lesson_elements;
xmlNodePtr current_node = xmlNewTextChild (parent_node, NULL,
BAD_CAST "group", NULL);
xmlSetProp (current_node, BAD_CAST "title",
BAD_CAST gpinstruct_lesson_element_get_title (GPINSTRUCT_LESSON_ELEMENT (group)));
xmlSetProp (current_node, BAD_CAST "single-score",
gpinstruct_lesson_element_group_get_single_score (group)?BAD_CAST "true":BAD_CAST "false");
xmlSetProp (current_node, BAD_CAST "single-directions",
gpinstruct_lesson_element_group_get_single_directions (group)?BAD_CAST "true":BAD_CAST "false");
xmlNewTextChild (current_node, NULL, BAD_CAST "directions",
BAD_CAST gpinstruct_lesson_element_group_get_directions (group));
lesson_elements = gpinstruct_lesson_element_group_get_lesson_elements (group);
curr_lesson_elements = lesson_elements;
while (curr_lesson_elements)
{
curr_lesson_element = GPINSTRUCT_LESSON_ELEMENT (curr_lesson_elements->data);
if (GPINSTRUCT_IS_LESSON_DISCUSSION (curr_lesson_element))
add_discussion (GPINSTRUCT_LESSON_DISCUSSION (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_READING (curr_lesson_element))
add_reading (GPINSTRUCT_LESSON_READING (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_TEST_MULTI_CHOICE (curr_lesson_element))
add_multi_choice_test (GPINSTRUCT_LESSON_TEST_MULTI_CHOICE (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_TEST_WORD_POOL (curr_lesson_element))
add_word_pool_test (GPINSTRUCT_LESSON_TEST_WORD_POOL (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_TEST_ORDER (curr_lesson_element))
add_order_test (GPINSTRUCT_LESSON_TEST_ORDER (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_TEST_TEXT (curr_lesson_element))
add_text_test (GPINSTRUCT_LESSON_TEST_TEXT (curr_lesson_element),
current_node);
else if (GPINSTRUCT_IS_LESSON_TEST_SCRAMBLED (curr_lesson_element))
add_scrambled_test (GPINSTRUCT_LESSON_TEST_SCRAMBLED (curr_lesson_element),
current_node);
curr_lesson_elements = curr_lesson_elements->next;
}
g_list_free (lesson_elements);
return current_node;
}
示例12: chatroom_manager_file_save
static gboolean
chatroom_manager_file_save (EmpathyChatroomManager *manager)
{
EmpathyChatroomManagerPriv *priv;
xmlDocPtr doc;
xmlNodePtr root;
GList *l;
priv = GET_PRIV (manager);
priv->writing = TRUE;
doc = xmlNewDoc ((const xmlChar *) "1.0");
root = xmlNewNode (NULL, (const xmlChar *) "chatrooms");
xmlDocSetRootElement (doc, root);
for (l = priv->chatrooms; l; l = l->next)
{
EmpathyChatroom *chatroom;
xmlNodePtr node;
const gchar *account_id;
chatroom = l->data;
if (!empathy_chatroom_is_favorite (chatroom))
continue;
account_id = tp_proxy_get_object_path (empathy_chatroom_get_account (
chatroom));
node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL);
xmlNewTextChild (node, NULL, (const xmlChar *) "name",
(const xmlChar *) empathy_chatroom_get_name (chatroom));
xmlNewTextChild (node, NULL, (const xmlChar *) "room",
(const xmlChar *) empathy_chatroom_get_room (chatroom));
xmlNewTextChild (node, NULL, (const xmlChar *) "account",
(const xmlChar *) account_id);
xmlNewTextChild (node, NULL, (const xmlChar *) "auto_connect",
empathy_chatroom_get_auto_connect (chatroom) ?
(const xmlChar *) "yes" : (const xmlChar *) "no");
xmlNewTextChild (node, NULL, (const xmlChar *) "always_urgent",
empathy_chatroom_is_always_urgent (chatroom) ?
(const xmlChar *) "yes" : (const xmlChar *) "no");
}
/* Make sure the XML is indented properly */
xmlIndentTreeOutput = 1;
DEBUG ("Saving file:'%s'", priv->file);
xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);
xmlFreeDoc (doc);
xmlMemoryDump ();
priv->writing = FALSE;
return TRUE;
}
示例13: uwsgi_webdav_add_a_prop
static void uwsgi_webdav_add_a_prop(xmlNode *node, char *opt, xmlNode *req_prop, int type, char *force_name) {
char *first_space = strchr(opt, ' ');
if (!first_space) return;
*first_space = 0;
char *second_space = strchr(first_space + 1, ' ');
xmlNode *new_node = NULL;
char *ns = opt;
if (!force_name) force_name = first_space + 1;
else {
ns = "DAV:";
}
if (second_space) {
*second_space = 0;
if (!uwsgi_webdav_prop_requested(req_prop, ns, force_name)) {
*first_space = ' ';
*second_space = ' ';
return;
}
// href
if (type == 1) {
new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
xmlNewTextChild(new_node, NULL, BAD_CAST "href", BAD_CAST second_space + 1);
}
// comp
else if (type == 2) {
new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
char *comps = uwsgi_str(second_space + 1);
char *p = strtok(comps, ",");
while(p) {
xmlNode *comp = xmlNewChild(new_node, NULL, BAD_CAST "comp", NULL);
xmlNewProp(comp, BAD_CAST "name", BAD_CAST p);
p = strtok(NULL, ",");
}
free(comps);
}
else {
if (!uwsgi_webdav_prop_requested(req_prop, ns, first_space + 1)) {
*first_space = ' ';
*second_space = ' ';
return;
}
new_node = xmlNewTextChild(node, NULL, BAD_CAST first_space + 1, BAD_CAST second_space + 1);
}
*second_space = ' ';
}
else {
if (!uwsgi_webdav_prop_requested(req_prop, ns, force_name)) {
*first_space = ' ';
return;
}
new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
}
xmlNsPtr x_ns = xmlNewNs(new_node, BAD_CAST opt, NULL);
xmlSetNs(new_node, x_ns);
*first_space = ' ';
}
示例14: build_key
static int
build_key (pskc_key_t * kp, xmlNodePtr keyp)
{
const char *id = pskc_get_key_id (kp);
const char *alg = pskc_get_key_algorithm (kp);
const char *issuer = pskc_get_key_issuer (kp);
const char *userid = pskc_get_key_userid (kp);
const char *keyprofileid = pskc_get_key_profileid (kp);
const char *keyreference = pskc_get_key_reference (kp);
const char *friendlyname = pskc_get_key_friendlyname (kp);
xmlNodePtr key;
int rc;
key = xmlNewChild (keyp, NULL, BAD_CAST "Key", NULL);
if (id && xmlNewProp (key, BAD_CAST "Id", BAD_CAST id) == NULL)
return PSKC_XML_ERROR;
if (alg && xmlNewProp (key, BAD_CAST "Algorithm", BAD_CAST alg) == NULL)
return PSKC_XML_ERROR;
if (issuer &&
xmlNewTextChild (key, NULL, BAD_CAST "Issuer", BAD_CAST issuer) == NULL)
return PSKC_XML_ERROR;
rc = build_algparm (kp, key);
if (rc != PSKC_OK)
return rc;
if (keyprofileid && xmlNewTextChild (key, NULL, BAD_CAST "KeyProfileId",
BAD_CAST keyprofileid) == NULL)
return PSKC_XML_ERROR;
if (keyreference && xmlNewTextChild (key, NULL, BAD_CAST "KeyReference",
BAD_CAST keyreference) == NULL)
return PSKC_XML_ERROR;
if (friendlyname && xmlNewTextChild (key, NULL, BAD_CAST "FriendlyName",
BAD_CAST friendlyname) == NULL)
return PSKC_XML_ERROR;
rc = build_data (kp, key);
if (rc != PSKC_OK)
return rc;
if (userid && xmlNewTextChild (key, NULL, BAD_CAST "UserId",
BAD_CAST userid) == NULL)
return PSKC_XML_ERROR;
rc = build_policy (kp, key);
if (rc != PSKC_OK)
return rc;
return PSKC_OK;
}
示例15: xmlNewTextChild
int LocalPackage::injectFile()
{
if (!dialogMode && verbose) say(string(_("Injecting file") + filename + "\n").c_str());
internal=true;
// Injecting data from file!
// If any of functions fails (e.g. return!=0) - break process and return failure code (!=0);
//int ret=0;
//mDebug("local_package.cpp: injectFile(): start");
//mDebug("get_xml");
if (get_xml()!=0)
{
//mDebug("local_package.cpp: injectFile(): get_xml FAILED");
return -3;
}
if (getExtension(filename)=="spkg") {
//printf("Source package detected, adding to XML\n");
xmlNewTextChild(_packageXMLNode, NULL, (const xmlChar *)"type", (const xmlChar *)"source");
data.set_type(PKGTYPE_SOURCE);
}
if (getExtension(filename)=="tgz" || getExtension(filename) == "txz" || getExtension(filename) == "tlz" ||getExtension(filename) == "tbz" ) {
xmlNewTextChild(_packageXMLNode, NULL, (const xmlChar *)"type", (const xmlChar *)"binary");
data.set_type(PKGTYPE_BINARY);
}
//mDebug("get_size()\n");
if (get_size()!=0)
{
mDebug("local_package.cpp: injectFile(): get_size() FAILED");
return -1;
}
//mDebug("create_md5\n");
if (create_md5()!=0)
{
mDebug("local_package.cpp: injectFile(): create_md5 FAILED");
return -2;
}
//mDebug("set_additional_data\n");
//mDebug("local_packaige.cpp: injectFile(): filename is "+ filename);
data.set_filename(filename);
if (set_additional_data()!=0)
{
mDebug("local_package.cpp: injectFile(): set_additional_data FAILED");
return -6;
}
delete_tmp_files();
//mDebug("local_package.cpp: injectFile(): end");
return 0;
}