cdata

XML CDATA not returning properly with simplexml_load_string() nor SimpleXMLElement() (PHP)

元气小坏坏 提交于 2019-12-04 05:54:55
问题 I can pull back any of the non-CDATA fields. But not the summary field. I've exhausted everything i know to try. Below is as close as i could get, with the summary field returning blank. It does return if i do a var_dump of the whole file of course, but then i can't access specific fields. Please help! Thanks! XML Sample <?xml version="1.0" encoding="utf-8"?> <zatom:feed xmlns:zatom="http://www.w3.org/2005/Atom" xmlns:z4m="http://namespaces.zope.com/zc/syndication" xmlns="http://www.w3.org

Is it possible to use CDATA inside <pre> tag

旧街凉风 提交于 2019-12-04 03:17:40
问题 I want to display an exception trace in the HTML page. One way to do this is to escape HTML special characters in the exception trace and dump it inside the <pre> tag. Although it works, it's terribly inefficient. I thought that one approach would be to wrap the trace with CDATA. I've tried it, but nothing get's displayed. My question, can this be done? Here is my feeble attempt. <pre><![CDATA[blah, blah, blah with <> and blah blah blah with & and more blah, blah]]></pre> 回答1: It would only

JSON - is there any XML CDATA equivalent?

非 Y 不嫁゛ 提交于 2019-12-03 22:07:55
I'm looking for a way that json parsing will take information as is (as if it was CDATA) - and not to try to serialize that. We use both .net and java (client and server) - so the answer should be about JSON structure Is there any way to achieve this structure? Thanks. almalki There is no XML CDATA equivalent in JSON. But you can encode your message in a string literal using something like base64. See this question for more details. http://www.json.org/ describes JSON format in details. According to it JSON doesn't support "something like CDATA" value type. To achieve CDATA structure you can

Storing the text of a stored procedure in an XML data type in SQL Server

百般思念 提交于 2019-12-03 18:13:18
问题 I need to store the text of all of the stored procedures in a database into an XML data type. When I use, FOR XML PATH , the text within in the stored procedure contains serialized data characters like and for CRLF and " , etc. I need the text to stored in the xml structure without these characters because the text will need to be used to recreate the stored procedure. This is the query that I use for FOR XML PATH : SELECT [View].name AS "@VName", [Module].definition AS "@VDefinition"

What is the prefered way handle “<![CDATA[” in a <![CDATA[ block?

余生长醉 提交于 2019-12-03 17:05:10
<![CDATA[ and ]]> are not allowed inside a <![CDATA[ … ]]> block. That is understandable. Now, I have to transmit user entered data inside a <![CDATA[ … ]]> block. And a malicious user might enter either <![CDATA[ or ]]> or both. The question is: what is the preferred way to handle this situation? Strip <![CDATA[ and ]]> ? Replace it with spaces? Smack the user with an error message? Or is there an official way of actually transmitting them? I think you are thinking about CDATA sections in the wrong way - CDATA stands for "Character data" and the CDATA syntax is simply syntax for a block of

How to get CDATA from xml node using xsl ?

梦想与她 提交于 2019-12-03 14:32:40
I am trying to get the CDATA content of an XML node using XSL. The node currently looks like this: <node id="1" text="Book Information" ><![CDATA[This is sample text]]></node> I need the This is sample text piece. Does anyone have any idea about this? Thanks in advance. Well, if I use this stylesheet: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="node/text()"> <xsl:copy/> </xsl:template> </xsl:stylesheet> on this XML file: <?xml version="1.0" encoding="utf-8"?> <node id=1

SimpleXML keeps returning content on CDATA element

 ̄綄美尐妖づ 提交于 2019-12-02 18:53:38
问题 So another CDATA returning content question. I've seen many answers, but even though I tried them all, I still get only content. In more details: I have an xml file (containing many NewsItem inside): <NewsML> <NewsItem> <NewsComponent> <ContentItem> <DataContent> <body> <body.content> <![CDATA[<p>This is what I am trying to retrieve</p>]]> </body.content> </body> </DataContent> </ContentItem> </NewsComponent> </NewsItem> I am trying to get the content of body.content. Here is my code: $xml =

Javascript to add cdata section on the fly?

孤人 提交于 2019-12-02 13:51:22
问题 I'm having trouble with special characters that exist in an xml node attribute. To combat this, I'm trying to render the attributes as child nodes and, where necessary, using cdata sections to get around the special characters. The problem is, I can't seem to get the cdata section appended to the node correctly. I'm iterating over the source xml node's attributes and creating new nodes. If the attribute.name = "description" I want to put the attribute.text() in a cdata section and append the

SimpleXML keeps returning content on CDATA element

╄→гoц情女王★ 提交于 2019-12-02 09:17:29
So another CDATA returning content question. I've seen many answers, but even though I tried them all, I still get only content. In more details: I have an xml file (containing many NewsItem inside): <NewsML> <NewsItem> <NewsComponent> <ContentItem> <DataContent> <body> <body.content> <![CDATA[<p>This is what I am trying to retrieve</p>]]> </body.content> </body> </DataContent> </ContentItem> </NewsComponent> </NewsItem> I am trying to get the content of body.content. Here is my code: $xml = simplexml_load_file('path/to/my/xml.xml',null,LIBXML_NOCDATA); if(count($xml->children()) > 0){ foreach

XSL unescape HTML inside CDATA

☆樱花仙子☆ 提交于 2019-12-02 04:07:48
问题 I'm trying to transform XML: <catalog> <country><![CDATA[ WIN8 <b>X</b> Mac OS ]]></country> </catalog> into <catalog> <country><![CDATA[ WIN8 <b>X</b> Mac OS ]]></country> </catalog> with an XSL transform. I know that using disable-output-escaping="yes" or cdata-section-elements I could transform escaped characters into unescaped and put inside CDATA, but this does not work if charaters are already inside CDATA. Is there a simple way for this? Thanks. 回答1: This <catalog> <country><![CDATA[