-1

I'm parsing xml that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<dataset
  xmlns:perinote="urn:perinote.com/perinote-1.2" >
...

And I'm wondering how I read the value for the "xmlns:perinote" tag. From there I want to be able to handle multiple versions.

I tried

String nameSpace = parser.getAttributeValue (null, "xmlns:perinote");

but it returns null.

Peri Hartman
  • 19,314
  • 18
  • 55
  • 101

2 Answers2

0

Ah, never mind. I think this is the correct solution:

String nameSpace = parser.getNamespaceUri (0);

As long as this is done immediately after parsing the "dataset" tag, I think it will be correct.

Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
0
String namespace = parser.getNamespace("perinote");
String attrValue = parser.getAttributeValue(namespace, "attributeName");
m-szalik
  • 3,546
  • 1
  • 21
  • 28