XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 25th, 2004, 04:36 AM
quique quique is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Ravensburg (Germany)
Posts: 7 quique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 43 sec
Reputation Power: 0
Question Editing XML with DOM (C++): inserting XML specifics

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

Reply With Quote
  #2  
Old March 25th, 2004, 06:04 AM
quique quique is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Ravensburg (Germany)
Posts: 7 quique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 43 sec
Reputation Power: 0
Thumbs up I found myself...

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Editing XML with DOM (C++): inserting XML specifics


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT