Hi,
I have a NodeList of path elements in an SVG file.
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
NodeList paths = document.getElementsByTagNameNS(svgNS,"path");
I am also creating an equal number of empty paths(by setting 'd' attribute as "").
numberOfPaths = paths.getLength();
path = new Element[numberOfPaths];
Now I want to set other attributes of these new paths to that of original paths(from the SVG file itself, instead of constant values). I am trying this(for example, the "stroke" attribute):
NamedNodeMap namedNodes = paths.item(i).getAttributes();
//path[i].setAttributeNS(null, "stroke", "#00ffff"); THIS WORKS FINE
path[i].setAttributeNS(svgNS, "stroke",namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());
And similarly for other attributes.
But I am getting NullPointerException. All the statements are in the order as written here. What could be the reason for this? Any thoughts?
--Piyush.
I have a NodeList of path elements in an SVG file.
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
NodeList paths = document.getElementsByTagNameNS(svgNS,"path");
I am also creating an equal number of empty paths(by setting 'd' attribute as "").
numberOfPaths = paths.getLength();
path = new Element[numberOfPaths];
Now I want to set other attributes of these new paths to that of original paths(from the SVG file itself, instead of constant values). I am trying this(for example, the "stroke" attribute):
NamedNodeMap namedNodes = paths.item(i).getAttributes();
//path[i].setAttributeNS(null, "stroke", "#00ffff"); THIS WORKS FINE
path[i].setAttributeNS(svgNS, "stroke",namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());
And similarly for other attributes.
But I am getting NullPointerException. All the statements are in the order as written here. What could be the reason for this? Any thoughts?
--Piyush.
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!