1

Here is the (simplified) XML I am currently working with:

<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="242.359" height="557.669" id="svg2" version="1.1" xmlns="http://www.w3.org/2000/svg">   
    <g transform="translate(71.9446563720703,1057.6692276001)">
        <!--nodes--> 
        <polygon stroke="#454545" stroke-opacity="1" stroke-width="1" fill="#00ff00" fill-opacity="1" points="11.35 -859.014 75 -822.719 138.65 -859.014 75 -895.31" />
        <text x="51.175" y="-852.249" font-family="Arial" font-size="16" fill="#121212">Node1</text>
        <ellipse fill="#00ff00" fill-opacity="1" stroke="#454545" stroke-opacity="1" stroke width="1" cx="0" cy="-571.945" rx="69.945" ry="69.945" />
        <text x="-61.945" y="-565.179" font-family="Arial" font-size="16" fill="#121212">Node2</text>
    </g>
</svg>

At a basic level, what I'm trying to accomplish is to get all of the "text" elements, not the shapes. Something as simple as:

List<XElement> textList = xml.Descendants("text").ToList();

But, this does not work. It has occurred to me that the XML may not have been serialized correctly, but I do not think this is the case. The XML is currently created with XElement.Parse() from a string. Specifically, the string is actually a SVG file, but I don't see how this would affect it's ability to act as XML. If this is why it isn't working it would be great to know that.

Atrus
  • 99
  • 1
  • 1
  • 9
  • The XML elements you want to match are namespaced. There are many answers on Stack Overflow on the topic of matching namespaced elements, I'd suggest you give it a try on your search engine of choice. – Frédéric Hamidi Feb 20 '13 at 21:39
  • Ah, that was it. I didn't know about the XML namespaces. I found the answer after a quick google search. Thank you! Answer was here: http://stackoverflow.com/questions/2338512/understanding-linq-to-xml-descendants-return-no-results – Atrus Feb 20 '13 at 21:45

0 Answers0