473,554 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to replace a perticular tag's content of an xml file with < instead of &lt; ?

23 New Member
Expand|Select|Wrap|Line Numbers
  1. <contact_us_client_email>
  2.     <message>
  3.         &lt;![CDATA[&lt;link href=\"http:/www.blurbpoint.com/style1.css\" rel=\"stylesheet\" type=\"text/css\" /&gt;
  4. &lt;div style=\"width: 900px; margin-left: auto; margin-right: auto;\"&gt;
  5.     &lt;div style=\"width: 900px; height: 100px; float: left; margin: 0pt 0pt 0pt 0px;\"&gt;
  6.         &lt;img src=\"http://www.blurbpoint.com/images/header.gif\" /&gt;&lt;/div&gt;
  7.     &lt;div style=\"width: 898px; float: left; margin: 0pt 0pt 0pt 0px; border-left: 1px solid rgb(197, 197, 197); border-right: 1px solid rgb(197, 197, 197);\"&gt;
  8.         &lt;div style=\"width: 900px; float: left; margin: 15px 0pt 0pt 0px; padding: 0pt 0pt 0pt 0px;\"&gt;
  9.             &lt;div style=\"width: 840px; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(35, 35, 35); margin: 0pt 0pt 0pt 14px; line-height: 16px;\"&gt;
  10.                 We have Sucessfully Received Your Inquiry. We will contact you.&lt;/div&gt;
  11.         &lt;/div&gt;
  12.         &lt;div style=\"width: 868px; float: left; margin: 15px 0pt 0pt 15px;\"&gt;
  13.             &lt;div style=\"width: 868px; float: left; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 25px; color: rgb(6, 91, 157);\"&gt;
  14.                 Customer Support&lt;/div&gt;
  15.             &lt;div style=\"border: 1px dashed rgb(140, 140, 140); width: 868px; float: left; margin: 5px 15px 0pt 0px;\"&gt;
  16.                 &lt;div style=\"width: 93px; float: left; margin: 15px 0pt 0pt 7px;\"&gt;
  17.                     &lt;img src=\"http://www.blurbpoint.com/images/customer_support_icon.gif\" /&gt;&lt;/div&gt;
  18.                 &lt;div style=\"width: 753px; float: left; margin: 15px 15px 10px 0px; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(40, 40, 40); text-decoration: none; line-height: 16px;\"&gt;
  19.                     Thanks a lot for visiting Blurbpoint.Our Customer Relationship Manager will be get back with top notch solutions soon. For any further queries contact support@blurbpoint.com&lt;/div&gt;
  20.             &lt;/div&gt;
  21.         &lt;/div&gt;
  22.         &lt;div style=\"width: 900px; border-top: 1px solid rgb(214, 214, 214); float: left; margin: 10px 0pt 10px 0px;\"&gt;
  23.             ]]&gt;
  24.     </message>
  25.  
  26.     <header>
  27.        <![CDATA[Content-Type: text/html;]]>From: support@blurbpoint.com
  28.     </header>
  29.  
  30. </contact_us_client_email>
  31.  
I am having problem that, after replacement, i did not get < in place of &lt; or > in place of &gt; because after the replacement output doesn't come in ckeditor where as source shows the code correctly but in that code <[CDATA[ comes like <--[CDATA[ So what should be done? My replacement file is like...

Expand|Select|Wrap|Line Numbers
  1. $doc = new DOMDocument;
  2. $doc->load('xml_mail_format2.xml');
  3. $playlist= $doc->documentElement;
  4.  
  5. $track = $playlist->getElementsByTagName("message")->item(0);
  6.  
  7. $newTrack = $doc->createElement('message',"<![CDATA[".$_POST['editor123']."]]>");
  8.  
  9. $oldtrack= $track->parentNode->replaceChild($newTrack,$track);
  10.  
  11. echo $doc->saveXML();
  12.  
  13. $doc->save("xml_mail_format2.xml");
  14.  
In this file $_POST['editor123'] contains the formatted design from ckeditor.
Feb 7 '11 #1
17 4243
Dormilich
8,658 Recognized Expert Moderator Expert
your intention is correct as you need to put the content in a CDATA section. however, a CDATA section is created differently (and because of that, your "CDATA section" is inserted as comment).
a CDATA section in XML is an own node type, therefore you have to create it explicitly: DOMDocument->createCDATASec tion($textConte nt);
Feb 7 '11 #2
Kaushal Elsner
23 New Member
Thank you very much for the reply. I just test it & then tell you that if it benefits me or not...will post reply soon for this.
Feb 7 '11 #3
Kaushal Elsner
23 New Member
Expand|Select|Wrap|Line Numbers
  1. $doc = new DOMDocument;
  2.  
  3. $doc->load('xml_mail_format2.xml');
  4.  
  5. $playlist= $doc->documentElement;
  6.  
  7. $track = $playlist->getElementsByTagName("message")->item(0);
  8.  
  9. $data = $doc->createCDATASection($data);
  10.  
  11. $newTrack = $doc->createElement('message',$data);
  12.  
  13. $oldtrack= $track->parentNode->replaceChild($newTrack,$track);
  14.  
  15. $doc->saveXML();
  16.  
  17. $doc->save("xml_mail_format2.xml");
  18.  
It is giving me 2 errors that :
1)Warning</b>: DOMDocument::cr eateElement() expects parameter 2 to be string, object given

2)Argument 1 passed to DOMNode::replac eChild() must be an instance of DOMNode, null given
Feb 7 '11 #4
Dormilich
8,658 Recognized Expert Moderator Expert
the second error is a follow up of the first error.

you attach a CDATA node like any other node (itís not text, after all), by DOMNode->appendChild( )
Feb 7 '11 #5
Kaushal Elsner
23 New Member
Should I send you the attachment of my xml & php file?
If you permit i send to you...I am waiting for your kind response. Thanks...
Feb 7 '11 #6
Dormilich
8,658 Recognized Expert Moderator Expert
why would you need to send me the files?
Feb 7 '11 #7
Kaushal Elsner
23 New Member
because i am not getting the thing done.I am still having errors so i asked to you. So if you permit then i will send you the 2 files.
Feb 7 '11 #8
Dormilich
8,658 Recognized Expert Moderator Expert
just post the php code (and the error messages) here.
Feb 7 '11 #9
Kaushal Elsner
23 New Member
Error Message :- DOMDocument::cr eateElement() expects parameter 2 to be string, object given.
Expand|Select|Wrap|Line Numbers
  1. $data = $_POST['editor123'];
  2.  
  3. $doc = new DOMDocument;
  4.  
  5. $doc->load('xml_mail_format2.xml');
  6.  
  7. $playlist= $doc->documentElement;
  8.  
  9. $track = $playlist->getElementsByTagName("message")->item(0);
  10.  
  11. $data = $doc->createCDATASection($data);
  12.  
  13. $newTrack = $doc->createElement('message',$data);
  14.  
  15. $oldtrack= $track->parentNode->replaceChild($newTrack,$track);
  16.  
  17. $doc->saveXML();
  18.  
  19. $doc->save("xml_mail_format2.xml");
  20.  
Can you tell me what changes should be made in the above code.Thanks in advance.
Feb 7 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2475
by: dpj5754 | last post by:
Is there a simple and determinist way to make the difference between the 2 sequences: <XX></XX> and <XX/> The EndElement callback does not provide this information.
4
62091
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I supposed to write this function? String.replace(/</g,'&lt;');
0
3104
by: Wolfgang Schwanke | last post by:
Dear usenet, I'm having the following small problem. I've been ask to add some Quicktime panoramas to a website. The author of the panoramas has made two versions of each: One in MOV format, which needs a Quicktime plugin, and one Java applet. He's also kindly supplied me with sample HTML code for each. The code looks like this...
7
2734
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The...
2
2051
by: Nicky | last post by:
hi, all I know we can do this by some jscript. But is there a way to do it in asp.net c# code? In our project, users could sumit a piece of html code and I need to remove all html tag out. What's the better way to do this? Thanks and have a wonderful holiday!
2
6830
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node as a value. Check out the following problem. I want to convert the value in <WpDatesXml> node to have a valid "<" and ">" instead of &lt or &gt...
14
3611
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good readibility on browsers w/o css-support. For important notes, warnings etc I use the <pre> tag, which shows in a neat bordered box when viewed...
6
24260
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an XSLT and replace all occurances of &lt; with < and &gt; with >.
5
3404
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done with moderate success using Saxon and <xsl:result-document>, but Saxon is throwing an error and I don't know how to resolve it. Maybe someone can offer...
0
1816
by: bingunginter | last post by:
I am using SQL 2005 server database. In my table I had fields that has chinese character (nvarchar type) and html tag <b></b>. I retrieve the table and display it in gridview. It displays the chinese character properly but it doesn't render the character in bold, instead it renders literaly as as '<b>..</b>'. How do I fix this?
0
7581
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main...
0
7506
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7782
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8018
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7872
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3545
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3533
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2006
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
823
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.