0

I have this code :

<st:friend xmlns:st='areacode:819'>
<st:name xmlns:st='urn:555'>Company</st:name>
<type>B</type>
</st:friend>

Can someone explain me why st is declared twice?

1
  • Thanks, (Yes I forgot the </sr:friend> at the end. But it's exactly what I was looking for, to understand, the urn:555 goes to ! <br> thanks again @Bruno Commented Dec 23, 2013 at 15:24

1 Answer 1

2

Your XML example isn't well formed as it does not close the <st:friend> element but I'll assume that you meant to close it after the <type> element.

What is going on here is that the <st:name> element is redefining what namespace the st prefix refers to (to urn:555). This definition applies to the <st:name> element only (and would apply to child elements too if there were any). Once you are past the closing tag <st:name/>, the st prefix refers again to its original namespace (areacode:819).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.