Hash Character in Xml Element Name

Hash Character in Xml Element Name

I'm running into an issue where I need to use a hashtag in the name of an XML node, and the hashtag is causing parsing errors. I've tried encoding the # without luck, perhaps I implemented the coding wrong.

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
    <properties#tags pk1="1" pk2="1" />
</dataset>

1 Answer

According to the XML specification, # is not a valid character in an XML name, so it won't work. You need to find another character.

Even trying to encode with &#35; or &#x23; for # will not allow you to use a character that isn't valid for an XML name.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.