Advertisements
Home > Misc > Exclude namespaces from XML using Jscript

Exclude namespaces from XML using Jscript

In one of my requirement I had to parse XML and find node values.

 My XML looks as below

<NS1:Envelope xmlns:NS1=http://schemas.xmlsoap.org/soap/envelope/>

<QueryBalanceResult>

<NS1:AvailableCredit>17400</NS1:AvailableCredit>

</QueryBalanceResult>

</NS1:Envelope>

Since the XML has got namespaces I need to exclude namespaces before I find the node. 

Below is the logic to exclude namespaces

var xmlWithNamespaces={Your xml with namespaces};

var xmlWithNoNamespaces= xmlWithNamespaces.replace(/<(\/?)([^:>\s]*:)?([^>]+)>/g, “<$1$3>”);

🙂

 

 

Advertisements
Categories: Misc Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: