Reading Node Title and Description

Jul 11, 2011 at 5:40 PM

I'm trying to read the title and description out of an svg file created with Inkscape.  However the data seems to be changing depending on whether there is a title, description, both, or neither.  Is this a bug, or is there a better way to access this information?  Thanks.

Test Code:

 

SvgRectangle rectangle = (SvgRectangle)document.Children[1].Children[0];
rectangleContent = rectangle.Content;
try
{
    SvgDescription description = (SvgDescription)rectangle.Children[0];
    descriptionContent = description.Content;
}
catch (Exception e)
{
    descriptionContent = "noDescription";
}
string Results = rectangleContent  + " & " + descriptionContent;

 

Results:

Both Title and Description: " & image/svg+xmlsampleTitlesampleDescription"

Only Title: "image/svg+xmlsampleTitle & noDescription"

Only Description: " & image/svg+xmlsampleDescription"

Neither Title or Description: "image/svg+xml & noDescription"

SVG Data:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="744.09448819"
   height="1052.3622047"
   id="svg2"
   version="1.1"
   inkscape:version="0.48.1 "
   sodipodi:docname="cameraStart.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.35"
     inkscape:cx="213.60288"
     inkscape:cy="316.7271"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     showborder="false"
     inkscape:window-width="850"
     inkscape:window-height="583"
     inkscape:window-x="222"
     inkscape:window-y="87"
     inkscape:window-maximized="0"
     showguides="false">
    <inkscape:grid
       type="xygrid"
       id="grid3757"
       empspacing="5"
       visible="true"
       enabled="true"
       snapvisiblegridlinesonly="true" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <rect
       style="fill:none;stroke:#00ffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
       id="rect2985"
       width="794"
       height="594"
       x="3"
       y="455.36218">
      <title
         id="title3767">sampleTitle</title>
      <desc
         id="desc3759">sampleDescription</desc>
    </rect>
  </g>
</svg>