Lxml XMLSyntaxError: Namespace default prefix was not found?

Ok, so I finally figured out what was going on. Following a good advice to clean up used elements, I was clearing up all the elements, including the root node. The root node is the one with the default namespace prefix which applies to all nodes within that root.

Since I cleared off my root node, the default namespace prefix was no longer a part of the nsmap of its subelements. The previous versions seem to be forgiving of this but the latest version was more strict in this sense.

Ok, so I finally figured out what was going on. Following a good advice to clean up used elements, I was clearing up all the elements, including the root node. The root node is the one with the default namespace prefix which applies to all nodes within that root.

Since I cleared off my root node, the default namespace prefix was no longer a part of the nsmap of its subelements. The previous versions seem to be forgiving of this but the latest version was more strict in this sense. Not clearing the root element untill I was done reading the xml did the trick for me.

Default namespace problems most often arise when you are attempting xpath expression. For just parsing the stream as in your sample, 2.3.0 should work fine with an unnamed default namespace. Perhaps you should post the smallest possible xml file that gives this error (line 545 is pretty deep into the file to have this error).

Thanks for your response Phil. I have added a sample of the xml in my original post and also edited the code sample to show how I am using the namespace. I basically compare the element tag to make sure it is what I expect it to be.In case an unknown tag is encountered, I log an error.

But here, the lxml just throws the error. I checked the line#545 to see if anything looked wrong there, but xml looks just fine (it should as it works fine with lxml 2.3 beta1). – Rinks Jun 28 at 20:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions