|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi everyone,
Let's go to the point, because I'm getting crazy looking for a solution in the "great" Ms Help pages, the source code of the header file and searching in this forum. Maybe I'm too close to the problem and I cannot see any further I'm developing an GUI interface to edit XML files, using Ms VC++ and DOM. The XML files have the following struct: Code:
<?xml...> .... <itemlist> <item> <text id="1">text 1</text> <text id="2">text 2</text> </item> ... My problem is, if a new id is created and it includes characters like '<' and '>'. For example, if the user defines a new id (3) and add as text: New text with <b>bold</b> chars The output XML shold be (for example): Code:
<?xml...> ... <itemlist> <item> <text id="1">text 1</text> <text id="2">text 2</text> <text id="3">New text with <b>bold</b> chars</text> </item> ... But I cannot get it to work. In this case, I try to create a new node (for id="3") and then insert the input text. After that, this new node will be added to the parent one and so, increase the list. Problems: 1) After creating the text, if I add the user input as using the put_text function, the < and > chars are converted to < and > 2) I created a new node witt value the user input: only the chars until '<' are inserted. The others are discard. 3) I tried to create a child node of type "text", "document fragment", "node" and add as property the user input (did not work, of course) 4) I searched for some way of "transforming" the input in a Node list. I did not find any. 5) Save the user input as CDATA value and then, transform this CDATA node in an ELEMENT node. I did not find a way to do the transformation. Only solutions in mind: A. Replace '>' and '<' for other chars, save the XML file and make an application that do the opposite conversion. Then, reopen the XML file. B. Go through the whole user input, searching for the special chars and divide the string in substrings. For each of this substrings, make a new node. A is very inelegant B has a very high probability of becoming errors and seems to much work for an easy problem Is there a easier/faster way to resolve this problem? ideas? where can I look for a solution? Kindly regards, Quique |
|
#2
|
|||
|
|||
|
Hi everone,
I found a solution: Create a new DOM document and set as content the user input, using the function loadXML. Then, get the list of nodes of this new document and add all of them to the parent. Regards/Saludos/Grüße, Quique |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Editing XML with DOM (C++): inserting XML specifics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|