Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embedding files in XML

Status
Not open for further replies.

victorsk

Programmer
Jul 26, 2005
21
CA
Hello,

I am trying to figure out how to embed a file in XML document. I am actually working with SVG but it's XML-based and I am trying to embed SVG file in XML document. Could somebody please tell me how?

Thank you,
Victor.
 
perhaps in a node defined as CDATA? this way the xml parser will not attempt to parse the node's content.

<myFile>
<![CDATA[
<xml>
<foo>FOO</foo>
</xml>
]]>
</myFile>

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Hi,

Thank you for replying. I am completely clueless when it comes to XML - my use of it is very limited. Would you please clarify where I should put "file.svg" in this code? does it go in place of 'FOO' as <SVG>"file.svg"</SVG>??? Sorry, XML is completely new to me.

Thank you,
Victor.
 
assuming you just want to get the literal text "<SVG>"file.svg"</SVG>" into an xml document, then:

<myFile>
<![CDATA[
<SVG>"file.svg"</SVG>
]]>
</myFile>


-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Hi,

Awesome! Thank you very much, my intuition was right.

Thank you,
Victor.
 
SVG is XML. You don't need to and shouldn't use CDATA. Just put the SVG wherever you want in the document. This is what namespaces are for - to differentiate between different XML. All you need to do is include the namespace:
Code:
<myXML>
  <anode>blah</anode>
  <anothernode>
<svg:svg width="300" height="300" version="1.1"
xmlns:svg="[URL unfurl="true"]http://www.w3.org/2000/svg">[/URL]
<svg:rect width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:1;
stroke:rgb(0,0,0)"/>
    </svg:svg>
  </anothernode>
</myXML>

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top