Adi
Adi

Reputation: 25

How to insert a break tag between words XML

I would like to insert a break tag between two words in product name below,

<product productName="Portable<br> Audio Recorder" productID="ABC" thumbPath="images/a1.jpg">

below is the complete XML code,

<category categoryName="New Arrival" categoryID="new-arrival">

    <product productName="Portable<br> Audio Recorder" productID="ABC" thumbPath="images/a1.jpg">

        <details>

            <![CDATA[

            <p><img src="images/a.jpg" width="100%"></p>

            ]]>

    </details>

    </product>

</category>

I have tried,

&#xA; \ <br> \ <![CDATA[<br/>]]> \ ("<br />") \ 

But still not working.. Please help me..

Upvotes: 0

Views: 103

Answers (2)

Vishal T
Vishal T

Reputation: 82

Everything except <, &, and your delimiter (' or ") are fine. For your reference

https://www.w3.org/TR/REC-xml/#NT-AttValue

Upvotes: 0

John Bollinger
John Bollinger

Reputation: 181932

You cannot put a tag of any sort in the place you want, because that's inside an attribute value. Attribute values do not contain tags, period. No matter what you put there, by definition, it is not a tag.

You can place any character you like, however. For example, you can insert a newline character via an entity reference. For example:

<product productName="Portable&#x0a; Audio Recorder" productID="ABC" thumbPath="images/a1.jpg">

Update:

You can also place characters into an attribute value that would constitute a tag elsewhere, but you must present the < via an entity reference:

<product productName="Portable&lt;br> Audio Recorder" productID="ABC" thumbPath="images/a1.jpg">

How that attribute value is interpreted by software that processes your XML is an altogether different question. Generally speaking, I would expect software that transforms the XML to take care to escape the text as necessary to preserve its textual interpretation in the destination context, but it's possible that yours does not do that. Consult your documentation.

Upvotes: 1

Related Questions