diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 10374ee..811051b 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -550,12 +550,14 @@
         const void *prefix_data, LY_PREFIX_FORMAT *format_p, void **prefix_data_p)
 {
     LY_ERR ret = LY_SUCCESS;
-    const char *start, *stop;
     const struct lys_module *mod;
     const struct lyxml_ns *ns;
     struct lyxml_ns *new_ns;
     struct ly_set *ns_list;
     struct lysc_prefix *prefixes = NULL, *val_pref;
+    const char *value_iter, *value_next, *value_end;
+    uint32_t substr_len;
+    ly_bool is_prefix;
 
     switch (format) {
     case LY_PREF_SCHEMA:
@@ -572,37 +574,25 @@
         }
 
         /* add all used prefixes */
-        for (stop = start = value; (size_t)(stop - value) < value_len; start = stop) {
-            size_t bytes;
-            uint32_t c;
+        value_end = value + value_len;
+        for (value_iter = value; value_iter; value_iter = value_next) {
+            substr_len = ly_value_prefix_next(value_iter, value_end, &is_prefix, &value_next);
+            if (is_prefix) {
+                /* we have a possible prefix. Do we already have the prefix? */
+                mod = ly_resolve_prefix(ctx, value_iter, substr_len, *format_p, *prefix_data_p);
+                if (!mod) {
+                    mod = ly_resolve_prefix(ctx, value_iter, substr_len, format, prefix_data);
+                    if (mod) {
+                        assert(*format_p == LY_PREF_SCHEMA_RESOLVED);
+                        /* store a new prefix - module pair */
+                        LY_ARRAY_NEW_GOTO(ctx, prefixes, val_pref, ret, cleanup);
+                        *prefix_data_p = prefixes;
 
-            ly_getutf8(&stop, &c, &bytes);
-            if (is_xmlqnamestartchar(c)) {
-                for (ly_getutf8(&stop, &c, &bytes);
-                        is_xmlqnamechar(c) && (size_t)(stop - value) < value_len;
-                        ly_getutf8(&stop, &c, &bytes)) {}
-                stop = stop - bytes;
-                if (*stop == ':') {
-                    /* we have a possible prefix */
-                    size_t len = stop - start;
-
-                    /* do we already have the prefix? */
-                    mod = ly_resolve_prefix(ctx, start, len, *format_p, *prefix_data_p);
-                    if (!mod) {
-                        mod = ly_resolve_prefix(ctx, start, len, format, prefix_data);
-                        if (mod) {
-                            assert(*format_p == LY_PREF_SCHEMA_RESOLVED);
-                            /* store a new prefix - module pair */
-                            LY_ARRAY_NEW_GOTO(ctx, prefixes, val_pref, ret, cleanup);
-                            *prefix_data_p = prefixes;
-
-                            val_pref->prefix = strndup(start, len);
-                            LY_CHECK_ERR_GOTO(!val_pref->prefix, LOGMEM(ctx); ret = LY_EMEM, cleanup);
-                            val_pref->mod = mod;
-                        } /* else it is not even defined */
-                    } /* else the prefix is already present */
-                }
-                stop = stop + bytes;
+                        val_pref->prefix = strndup(value_iter, substr_len);
+                        LY_CHECK_ERR_GOTO(!val_pref->prefix, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+                        val_pref->mod = mod;
+                    } /* else it is not even defined */
+                } /* else the prefix is already present */
             }
         }
         break;
@@ -620,38 +610,26 @@
         }
 
         /* add all used prefixes */
-        for (stop = start = value; (size_t)(stop - value) < value_len; start = stop) {
-            size_t bytes;
-            uint32_t c;
+        value_end = value + value_len;
+        for (value_iter = value; value_iter; value_iter = value_next) {
+            substr_len = ly_value_prefix_next(value_iter, value_end, &is_prefix, &value_next);
+            if (is_prefix) {
+                /* we have a possible prefix. Do we already have the prefix? */
+                ns = lyxml_ns_get(ns_list, value_iter, substr_len);
+                if (!ns) {
+                    ns = lyxml_ns_get(prefix_data, value_iter, substr_len);
+                    if (ns) {
+                        /* store a new prefix - namespace pair */
+                        new_ns = calloc(1, sizeof *new_ns);
+                        LY_CHECK_ERR_GOTO(!new_ns, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+                        LY_CHECK_GOTO(ret = ly_set_add(ns_list, new_ns, 1, NULL), cleanup);
 
-            ly_getutf8(&stop, &c, &bytes);
-            if (is_xmlqnamestartchar(c)) {
-                for (ly_getutf8(&stop, &c, &bytes);
-                        is_xmlqnamechar(c) && (size_t)(stop - value) < value_len;
-                        ly_getutf8(&stop, &c, &bytes)) {}
-                stop = stop - bytes;
-                if (*stop == ':') {
-                    /* we have a possible prefix */
-                    size_t len = stop - start;
-
-                    /* do we already have the prefix? */
-                    ns = lyxml_ns_get(ns_list, start, len);
-                    if (!ns) {
-                        ns = lyxml_ns_get(prefix_data, start, len);
-                        if (ns) {
-                            /* store a new prefix - namespace pair */
-                            new_ns = calloc(1, sizeof *new_ns);
-                            LY_CHECK_ERR_GOTO(!new_ns, LOGMEM(ctx); ret = LY_EMEM, cleanup);
-                            LY_CHECK_GOTO(ret = ly_set_add(ns_list, new_ns, 1, NULL), cleanup);
-
-                            new_ns->prefix = strndup(start, len);
-                            LY_CHECK_ERR_GOTO(!new_ns->prefix, LOGMEM(ctx); ret = LY_EMEM, cleanup);
-                            new_ns->uri = strdup(ns->uri);
-                            LY_CHECK_ERR_GOTO(!new_ns->uri, LOGMEM(ctx); ret = LY_EMEM, cleanup);
-                        } /* else it is not even defined */
-                    } /* else the prefix is already present */
-                }
-                stop = stop + bytes;
+                        new_ns->prefix = strndup(value_iter, substr_len);
+                        LY_CHECK_ERR_GOTO(!new_ns->prefix, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+                        new_ns->uri = strdup(ns->uri);
+                        LY_CHECK_ERR_GOTO(!new_ns->uri, LOGMEM(ctx); ret = LY_EMEM, cleanup);
+                    } /* else it is not even defined */
+                } /* else the prefix is already present */
             }
         }
         break;
