MCPcopy Create free account
hub / github.com/NaturalIntelligence/fast-xml-parser / extractNamespace

Function extractNamespace

src/xmlparser/OrderedObjParser.js:59–71  ·  view source on GitHub ↗

* Extract namespace from raw tag name * @param {string} rawTagName - Tag name possibly with namespace (e.g., "soap:Envelope") * @returns {string|undefined} Namespace or undefined

(rawTagName)

Source from the content-addressed store, hash-verified

57 * @returns {string|undefined} Namespace or undefined
58 */
59function extractNamespace(rawTagName) {
60 if (!rawTagName || typeof rawTagName !== 'string') return undefined;
61
62 const colonIndex = rawTagName.indexOf(':');
63 if (colonIndex !== -1 && colonIndex > 0) {
64 const ns = rawTagName.substring(0, colonIndex);
65 // Don't treat xmlns as a namespace
66 if (ns !== 'xmlns') {
67 return ns;
68 }
69 }
70 return undefined;
71}
72
73export default class OrderedObjParser {
74 constructor(options, externalEntities) {

Callers 1

parseXmlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected