findNode() and xmlns namespaces
Posted: Sat Nov 19, 2016 1:26 pm
Hi,
in XML files I can define namespace like:
xmlns:tns="http://........"
Then in xml file the tag look like:
<tns:SampleNode></tns:SampleNode>
Problem is, that in some XML files, programmers change prefix for namespaces. File:
<?xml version="1.0" encoding="UTF-8"?>
<Deklaracja xmlns="http://crd.gov.pl/wzor/2011/">
<Naglowek>
<WariantFormularza>19</WariantFormularza>
<Rok>2011</Rok>
<KodUrzedu>3023</KodUrzedu>
</Naglowek>
</Deklaracja>
and file:
<?xml version="1.0" encoding="UTF-8"?>
<tns:Deklaracja xmlns:tns="http://crd.gov.pl/wzor/2011/">
<tns:Naglowek>
<tns:WariantFormularza>19</tns:WariantFormularza>
<tns:Rok>2011</tns:Rok>
<tns:KodUrzedu>3023</tns:KodUrzedu>
</tns:Naglowek>
</tns:Deklaracja>
are valid with the same XSD schema. But the findNode() search the tag complete with prefix. Searching findNode('Naglowek') in first file have succes, but in second - no. How solve this problem?
Piotr
in XML files I can define namespace like:
xmlns:tns="http://........"
Then in xml file the tag look like:
<tns:SampleNode></tns:SampleNode>
Problem is, that in some XML files, programmers change prefix for namespaces. File:
<?xml version="1.0" encoding="UTF-8"?>
<Deklaracja xmlns="http://crd.gov.pl/wzor/2011/">
<Naglowek>
<WariantFormularza>19</WariantFormularza>
<Rok>2011</Rok>
<KodUrzedu>3023</KodUrzedu>
</Naglowek>
</Deklaracja>
and file:
<?xml version="1.0" encoding="UTF-8"?>
<tns:Deklaracja xmlns:tns="http://crd.gov.pl/wzor/2011/">
<tns:Naglowek>
<tns:WariantFormularza>19</tns:WariantFormularza>
<tns:Rok>2011</tns:Rok>
<tns:KodUrzedu>3023</tns:KodUrzedu>
</tns:Naglowek>
</tns:Deklaracja>
are valid with the same XSD schema. But the findNode() search the tag complete with prefix. Searching findNode('Naglowek') in first file have succes, but in second - no. How solve this problem?
Piotr