cdata

Is CDATA really necessary?

允我心安 提交于 2020-01-14 07:56:06
问题 I use inline Javascript quite a bit, usually in WordPress themes that I make. I had not heard of wrapping inline Javascript in //<![CDATA[ ... //]]> up until a few months ago, and I have been doing this stuff at a fair level of competency for a few years. I googled around and I hear that people use this because their Javascript doesn't validate otherwise. I use a strict 1.0 xHTML doctype and have never had a problem validating my markup. Is it because I use jquery, or because usually I only

Modify ![CDATA[]] in PHP? (XML)

落爺英雄遲暮 提交于 2020-01-11 10:38:07
问题 I have an XML file which contains ![CDATA[]] data. Like this: <link><![CDATA[https://google.de]]></link> Now I heard that I can not modify ![CDATA[]] data or that they contains some special characters. But I do not remember anymore... That's the reason why I'am asking here. Can I change the values in ![CDATA[]] and if yes, how? I just want to append something like "?=dadc" on the link. Edit: My XML file structure (Want to edit the url): <?xml version="1.0" encoding="UTF-8"?> <rss> <channel

what xpath to select CDATA content when some childs exist

孤者浪人 提交于 2020-01-10 05:16:12
问题 Let's say I have an XML that looks like this: <a> <b> <![CDATA[some text]]> <c>xxx</c> <d>yyy</d> </b> </a> I can't find a way to get "some text". Any idea? If I'm using "a/b" it returns also xxx and yyy If I'm using "a/b/text()" it returns nothing 回答1: You can't actually select a CDATA section: CDATA is just a way of telling the parser to avoid unescaping special characters, and your input document looks to XPath exactly the same as: <a> <b> some text <c>xxx</c> <d>yyy</d> </b> </a> (Having

How do I add CDATA to an xml file?

女生的网名这么多〃 提交于 2020-01-06 12:53:23
问题 I have an existing xml file that holds notifications I want to display on my site. A snippet follows: <contents> <item> <![CDATA[ <a style="font-weight: bold;" href="http://engadget.com">Engadget</a> ]]> </item> <item> <![CDATA[ <a style="font-weight: bold;" href="http://cnn.com">CNN</a> ]]> </item> </contents> I'm trying to open this document and add new "items" to it, but I can't: foreach (string s in notifications) { XmlElement newElement = doc.CreateElement("item"); newElement.InnerXml =

XSLT - How to manage CDATA as common content?

六眼飞鱼酱① 提交于 2020-01-06 06:30:07
问题 I am trying to use xslt to render an xml file generated by a software in use at my work. There are some CDATA content in the xml. When I transform it the content of the CDATA is displayed as text but I would like it is only not shown. I found a way to make it empty so that nothing appear while I don't need to exploit it but I have to manage all cases. My question is : How can I manage all the CDATA content as standard text (accessible with value-of) so that it will not appear while I don't

<![CDATA in SimplePie

。_饼干妹妹 提交于 2020-01-06 04:09:42
问题 I've been working on some RSS Scrapper that parses data from multiple sources. That said, all this sources have their own implementation of the description of the RSS. One in particular, uses CDATA tags to write the description on like, for example <![CDATA[ <p align=justify><font face="verdana, arial, helvetica, sans-serif" size=1> <font color=#004080></font> SOME TEXT GOES HERE </font></p> ]]> However if I try to get the item description with SimplePie I get this output <div><p align=

<![CDATA in SimplePie

社会主义新天地 提交于 2020-01-06 04:08:10
问题 I've been working on some RSS Scrapper that parses data from multiple sources. That said, all this sources have their own implementation of the description of the RSS. One in particular, uses CDATA tags to write the description on like, for example <![CDATA[ <p align=justify><font face="verdana, arial, helvetica, sans-serif" size=1> <font color=#004080></font> SOME TEXT GOES HERE </font></p> ]]> However if I try to get the item description with SimplePie I get this output <div><p align=

Forcing Empty CDATA Elements

别等时光非礼了梦想. 提交于 2020-01-06 01:52:06
问题 I was questioned if i could transform an xml by using xsl (1.0) but with keeping the CDATA elements even if there is no content in it. As xsl beginner i am a little bit overwhelmed by that question... here is a simple sample. what i have <AMOUNT/> what i want <AMOUNT><![CDATA[]]></AMOUNT> is there a way to force empty cdata segments with no content? Is there a way to do it for all elements in the file? Is there a way to do it just for the ones in the cdata-section-elements ? (have a look at

jquery set xml cdata

余生颓废 提交于 2020-01-04 05:19:10
问题 I have a problem setting a cdata node with jquery. Getting cdata is easily done with the .text() function, but if I use .text('jquery > handy') it doesn't create a cdata node. This is my procecure: I get form data in xml to load in a form something like this: <formdata> <field id="title"><![CDATA[Some title]]></field> <field id="description"><![CDATA[Some description]]></field> </formdata> I use cdata nodes because a field can contain all kinds of special chars. Then I load the data in the

java adding cdata to xml string

风流意气都作罢 提交于 2020-01-02 08:02:34
问题 I need to add CDATA to xml string for sign it with certificate. String looks like: <SignedContent>someparametres</SignedContent> Result must be like: <![CDATA[<SignedContent>someparametres</SignedContent>]]> How can i do this? Pls help P.S. Xml string has only one row (removed all tabs, all spaces, BOM) 回答1: It sounds like you just want: Node cdata = doc.createCDATASection(text); parentElement.appendChild(cdata); 回答2: This post may be hold but i feel i should respond, this may help someone