/* * Class: org_xmlsoft_Node * Method: setTextImpl * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_xmlsoft_Node_setTextImpl (JNIEnv *env, jobject obj, jstring jstr) { xmlNode *node = findNode(env, obj); const xmlChar *str = (const xmlChar*)(*env)->GetStringUTFChars(env, jstr, NULL); xmlNodeSetContent(node, str); (*env)->ReleaseStringUTFChars(env, jstr, (const char*)str); }
/* only change the menory */ int ermXmlSetString(erManifest *pCtx, const char *express, const char *pData) { xmlXPathObjectPtr xpathObj = LocateTo(express, pCtx); if (NULL == xpathObj) return RET_ERR; xmlNodeSetPtr nodes = xpathObj->nodesetval; /* MvdW: we need to encode special chars in the input */ xmlChar *xmlString = xmlEncodeSpecialChars(pCtx->pDoc, (xmlChar *) pData); if (nodes && nodes->nodeTab[0]) { xmlNodeSetContent(nodes->nodeTab[0], xmlString); xmlFree(xmlString); /* See http://www.xmlsoft.org/examples/xpath2.c for detail */ if (nodes->nodeTab[0]->type != XML_NAMESPACE_DECL) nodes->nodeTab[0] = NULL; xmlXPathFreeObject(xpathObj); return RET_OK; } xmlXPathFreeObject(xpathObj); return RET_ERR; }
void XMLFile::Set( const string& path, const string& value ) { LogMsg(INFO,"Overriding Option['%s'] from '%s' to '%s'",path.c_str(),Get(path).c_str(),value.c_str()); xmlNodePtr p = FindNode(path,true); xmlNodeSetContent(p, BAD_CAST value.c_str() ); LogMsg(INFO,"Done Overriding Option['%s'] to '%s'",path.c_str(),Get(path).c_str()); assert( value == Get(path)); }
xmlNodePtr xmlAddStringNode( xmlNodePtr root, const char * name, const char * val ) { xmlNodePtr node = xmlNewChild( root, NULL, (const xmlChar *)name, NULL ); xmlNodeSetContent(node, (const xmlChar *)val); return node; }
// Set coodinates for a node, carried as the content of a child. void xmlSetCoordinates (xmlNodePtr node, const char *name, double x1, double y1, double x2, double y2) { xmlNodePtr child; gchar *str; xmlChar *ret; str = g_strdup_printf ("(%g %g)(%g %g)", x1, y1, x2, y2); ret = xmlGetProp (node, BAD_CAST name); if (ret != NULL) { xmlSetProp (node, BAD_CAST name, BAD_CAST str); g_free (str); return; } child = node->childs; while (child != NULL) { if (!xmlStrcmp (child->name, BAD_CAST name)) { xmlNodeSetContent (child, BAD_CAST str); return; } child = child->next; } xmlSetProp (node, BAD_CAST name, BAD_CAST str); g_free (str); }
static void impl_save_contents_to_xml (RBPlaylistSource *source, xmlNodePtr node) { RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source); GtkTreeIter iter; xmlSetProp (node, RB_PLAYLIST_TYPE, RB_PLAYLIST_STATIC); if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->base_model), &iter)) return; do { xmlNodePtr child_node = xmlNewChild (node, NULL, RB_PLAYLIST_LOCATION, NULL); RhythmDBEntry *entry; xmlChar *encoded; const char *location; gtk_tree_model_get (GTK_TREE_MODEL (priv->base_model), &iter, 0, &entry, -1); location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); encoded = xmlEncodeEntitiesReentrant (NULL, BAD_CAST location); xmlNodeSetContent (child_node, encoded); g_free (encoded); rhythmdb_entry_unref (entry); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->base_model), &iter)); }
BOOL CLibXmlXmlParser::SetElementValue( LPCTSTR strElementName, LPCTSTR strValue ) { BOOL bResult = FALSE; if( this->m_pXMLRootNode ) { xmlNodePtr pChild = this->m_pXMLRootNode->children; while( pChild ) { if( xmlStrcmp( pChild->name , BAD_CAST(strElementName) ) == 0 ) { break; } pChild = pChild->next; } if( !pChild ) { // pChild = xmlNewNode(NULL , BAD_CAST ( strEleName )); pChild = xmlNewChild( this->m_pXMLRootNode, NULL, BAD_CAST(strElementName), BAD_CAST(strValue) ); } if( pChild ) { xmlNodeSetContent( pChild, BAD_CAST( strValue ) ); //pChild->content = BAD_CAST( strValue ); } bResult = ( NULL != pChild ); } // 写完保存。 bResult &= this->SaveXML(); return bResult; }
// all output ends up through here void FPrintf (int flag, char *buf) { xmlNodePtr node; static qboolean bGotXML = false; char level[2]; printf(buf); // the following part is XML stuff only.. but maybe we don't want that message to go down the XML pipe? if (flag == SYS_NOXML) return; // ouput an XML file of the run // use the DOM interface to build a tree /* <message level='flag'> message string .. various nodes to describe corresponding geometry .. </message> */ if (!bGotXML) { // initialize doc = xmlNewDoc("1.0"); doc->children = xmlNewDocRawNode(doc, NULL, "q3map_feedback", NULL); bGotXML = true; } node = xmlNewNode (NULL, "message"); xmlNodeSetContent (node, buf); level[0] = (int)'0' + flag; level[1] = 0; xmlSetProp (node, "level", (char *)&level ); xml_SendNode (node); }
static void init_uuid (void) { xmlNode *uuid_node; char *udn; uuid = gupnp_get_uuid (); uuid_node = xml_util_get_element ((xmlNode *) doc->doc, "root", "device", "UDN", NULL); if (uuid_node == NULL) { g_critical ("Failed to find UDN element" "in device description"); return; } udn = g_strdup_printf ("uuid:%s", uuid); xmlNodeSetContent (uuid_node, (unsigned char *) udn); g_free (udn); }
void KmlRenderer::renderGlyphs(imageObj *img, pointObj *labelpnt, char *text, double angle, colorObj *clr, colorObj *olcolor, int olwidth) { xmlNodePtr node; if (PlacemarkNode == NULL) PlacemarkNode = createPlacemarkNode(LayerNode, NULL); if (!PlacemarkNode) return; memcpy(&LabelColor, clr, sizeof(colorObj)); SymbologyFlag[Label] = 1; /*there is alaws a default name (layer.shapeid). Replace it*/ for (node = PlacemarkNode->children; node; node = node->next) { if (node->type != XML_ELEMENT_NODE) continue; if (strcmp((char *)node->name, "name") == 0) { xmlNodeSetContent(node, BAD_CAST text); break; } } /*xmlNewChild(PlacemarkNode, NULL, BAD_CAST "name", BAD_CAST text);*/ xmlNodePtr geomNode = getGeomParentNode("Point"); addAddRenderingSpecifications(geomNode); pointObj pt; pt.x = labelpnt->x; pt.y = labelpnt->y; addCoordsNode(geomNode, &pt, 1); }
int SXmlNode::SetContent(std::string value) { if (!_node) return -1; xmlNodeSetContent(_node, BAD_CAST value.c_str()); return 0; }
int dom_node_text_content_write(dom_object *obj, zval *newval) { xmlNode *nodep = dom_object_get_node(obj); zend_string *str; if (nodep == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0); return FAILURE; } if (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE) { if (nodep->children) { node_list_unlink(nodep->children); php_libxml_node_free_list((xmlNodePtr) nodep->children); nodep->children = NULL; } } str = zval_get_string(newval); /* we have to use xmlNodeAddContent() to get the same behavior as with xmlNewText() */ xmlNodeSetContent(nodep, (xmlChar *) ""); xmlNodeAddContent(nodep, (xmlChar *) ZSTR_VAL(str)); zend_string_release_ex(str, 0); return SUCCESS; }
osync_bool osync_xmlfield_set_key_value(OSyncXMLField *xmlfield, const char *key, const char *value, OSyncError **error) { xmlNodePtr cur = NULL; osync_assert(xmlfield); osync_assert(key); // If value is null we don't add it to a xmlfield if (!value) return TRUE; cur = xmlfield->node->children; for(; cur != NULL; cur = cur->next) { if(!xmlStrcmp(cur->name, BAD_CAST key)) { xmlNodeSetContent(xmlfield->node, BAD_CAST value); break; } } /* TODO: error handling */ if(cur == NULL) cur = xmlNewTextChild(xmlfield->node, NULL, BAD_CAST key, BAD_CAST value); if (!osync_xmlfield_new_xmlfield(xmlfield, cur, error)) goto error; xmlfield->sorted = FALSE; return TRUE; error: return FALSE; }
/* * call-seq: * content= * * Set the content for this Node */ static VALUE set_content(VALUE self, VALUE content) { xmlNodePtr node; Data_Get_Struct(self, xmlNode, node); xmlNodeSetContent(node, (xmlChar *)StringValuePtr(content)); return content; }
static xmlChar * vshMakeCloneXML(const char *origxml, const char *newname) { xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; xmlXPathObjectPtr obj = NULL; xmlChar *newxml = NULL; int size; doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt); if (!doc) goto cleanup; obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt); if (obj == NULL || obj->nodesetval == NULL || obj->nodesetval->nodeTab == NULL) goto cleanup; xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newname); xmlDocDumpMemory(doc, &newxml, &size); cleanup: xmlXPathFreeObject(obj); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return newxml; }
void go_xml_node_set_cstr (xmlNodePtr node, char const *name, char const *val) { if (name) xmlSetProp (node, CC2XML (name), CC2XML (val)); else xmlNodeSetContent (node, CC2XML (val)); }
static void update_string(xmlDocPtr doc, xmlNodePtr dest, const xmlChar* newstr) { /* TODO: do we need xmlEncodeEntitiesReentrant() too/instead? */ xmlChar* string = xmlEncodeSpecialChars(doc, newstr); xmlNodeSetContent(dest, string); xmlFree(string); }
void modifyStory(xmlNodePtr cur) { xmlChar *value = NULL; value = xmlNodeGetContent(cur); printf("content %s\n", value); xmlNodeSetContent(cur, (const xmlChar *)"192.168.15.22:4567"); xmlFree(value); }
int dialog_offline_body(str* body, str** offline_body) { xmlDocPtr doc= NULL; xmlNodePtr node; xmlErrorPtr xml_error; str* new_body = NULL; char *err_msg; int rc = OFFB_STATUS_ERROR; if (!offline_body) { LM_ERR("invalid parameter"); return OFFB_STATUS_ERROR; } *offline_body = NULL; doc= xmlParseMemory(body->s, body->len); if(doc== NULL) { GET_LAST_XML_ERROR(xml_error, err_msg); LM_ERR("xml memory parsing failed: %s\n", err_msg); goto done; } node= xmlDocGetNodeByName(doc, "dialog", NULL); if(node== NULL) { LM_DBG("no dialog nodes found"); rc = OFFB_STATUS_NO_DIALOG; goto done; } node= xmlNodeGetChildByName(node, "state"); if(node== NULL) { LM_ERR("while extracting state node\n"); goto done; } xmlNodeSetContent(node, (const unsigned char*)"terminated"); new_body = (str*)pkg_malloc(sizeof(str)); if(new_body == NULL) { LM_ERR("No more pkg memory"); goto done; } memset(new_body, 0, sizeof(str)); xmlDocDumpMemory(doc,(xmlChar**)(void*)&new_body->s, &new_body->len); *offline_body = new_body; rc = OFFB_STATUS_OK; done: if (doc) xmlFreeDoc(doc); return rc; }
void tree_set_bool(const gchar *node, const gboolean value) { xmlNodePtr n; n = tree_get_node(node, NULL); xmlNodeSetContent(n, (const xmlChar*) (value ? "yes" : "no")); tree_apply(); }
void tree_set_string(const gchar *node, const gchar *value) { xmlNodePtr n; n = tree_get_node(node, NULL); xmlNodeSetContent(n, (const xmlChar*) value); tree_apply(); }
bool CSpmXml::SetContent(const QString& strContent, xmlNodePtr pNode) { pNode = GetNode(pNode); if (0 == pNode) return false; xmlNodeSetContent(pNode, BAD_CAST strContent.toUtf8().data()); return true; }
// some useful stuff xmlNodePtr xml_NodeForVec( vec3_t v ){ xmlNodePtr ret; char buf[1024]; sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); ret = xmlNewNode( NULL, (xmlChar*)"point" ); xmlNodeSetContent( ret, (xmlChar*)buf ); return ret; }
value v2v_xml_node_ptr_set_content (value nodev, value contentv) { CAMLparam2 (nodev, contentv); xmlNodePtr node = (xmlNodePtr) nodev; xmlNodeSetContent (node, BAD_CAST String_val (contentv)); CAMLreturn (Val_unit); }
xmlNodePtr xmlAddDoubleNode( xmlNodePtr root, const char * name, double val ) { char str[255]; xmlNodePtr node = xmlNewChild( root, NULL, (const xmlChar *)name, NULL ); sprintf( str, "%lf", val ); xmlNodeSetContent(node, (const xmlChar *)str); return node; }
XMLNode::XMLNode( const String& name,const String& content ) :m_data( new NodeData ){ m_data->m_node = xmlNewNode( Nullptr, reinterpret_cast<const xmlChar *>(name.toString().c_str()) ); if( Nullptr != m_data->m_node ){ xmlNodeSetContent( m_data->m_node, reinterpret_cast<const xmlChar *>( content.toString().c_str() ) ); m_data->m_name = name; m_data->m_content = content; } }
static void add_text_to_node(xmlNodePtr node, const gchar *type, gchar *val) { gchar *newtype = g_strdup (type); gchar *newval = g_strdup (val); xmlSetProp(node, BAD_CAST "type", BAD_CAST type); xmlNodeSetContent(node, checked_char_cast (val)); g_free (newtype); g_free(newval); }
void XMLFile::Set( const string& path, const int value ) { // Convert the int to a string before saving it. string stringvalue; stringstream val_ss; val_ss << value; val_ss >> stringvalue; LogMsg(INFO,"Overriding Option['%s'] from '%s' to '%s'",path.c_str(),Get(path).c_str(),stringvalue.c_str()); xmlNodeSetContent(FindNode(path,true), BAD_CAST stringvalue.c_str() ); assert( stringvalue == Get(path)); }
/* * call-seq: * node.content = "string" * * Set this node's content to the specified string. */ static VALUE rxml_node_content_set(VALUE self, VALUE content) { xmlNodePtr xnode; Check_Type(content, T_STRING); Data_Get_Struct(self, xmlNode, xnode); // XXX docs indicate need for escaping entites, need to be done? danj xmlNodeSetContent(xnode, (xmlChar*) StringValuePtr(content)); return (Qtrue); }
int DEFAULT_CC xml_send_error(int client, const char* message) { xmlChar* xmlbuff; xmlDocPtr doc; xmlNodePtr node; struct stream* s; int buff_size, size; xmlChar* version; xmlChar* error; xmlChar* msg; version = xmlCharStrdup("1.0"); doc = xmlNewDoc(version); if (doc == NULL) { log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "sesman[xml_send_error]: " "Unable to create the document"); xmlFree(version); return 0; } error = xmlCharStrdup("error"); msg = xmlCharStrdup(message); doc->encoding = xmlCharStrdup("UTF-8"); node = xmlNewNode(NULL, error); xmlNodeSetContent(node, msg); xmlDocSetRootElement(doc, node); xmlDocDumpFormatMemory(doc, &xmlbuff, &buff_size, 1); log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "sesman[xml_send_error]: " "data send : %s",xmlbuff); make_stream(s); init_stream(s, buff_size + 6); out_uint32_be(s,buff_size); out_uint8p(s, xmlbuff, buff_size) size = s->p - s->data; if (g_tcp_can_send(client, 10)) { buff_size = g_tcp_send(client, s->data, size, 0); } else { log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[xml_send_error]: " "Unable to send xml response: %s, cause: %s", xmlbuff, strerror(g_get_errno())); } free_stream(s); xmlFreeDoc(doc); xmlFree(xmlbuff); xmlFree(version); xmlFree(error); xmlFree(msg); return buff_size; }