DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • How to Convert XLS to XLSX in Java
  • Thread-Safety Pitfalls in XML Processing
  • Loading XML into MongoDB
  • SmartXML: An Alternative to XPath for Complex XML Files

Trending

  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Next Evolution in Integration: Architecting With Intent Using Model Context Protocol
  • Building Resilient Networks: Limiting the Risk and Scope of Cyber Attacks
  • Building Resilient Identity Systems: Lessons from Securing Billions of Authentication Requests
  1. DZone
  2. Coding
  3. Languages
  4. Mule Dynamic Namespace

Mule Dynamic Namespace

Learn more about namespaces in Mule with this look at XMLs with dynamice namespaces.

By 
Anirban Sen Chowdhary user avatar
Anirban Sen Chowdhary
·
Updated Feb. 26, 16 · Analysis
Likes (2)
Comment
Save
Tweet
Share
9.9K Views

Join the DZone community and get the full member experience.

Join For Free

We often have a requirement of extracting values from nodes of complex XML. We use XPATH3 in our Mule expression to extract different values from different nodes. For the complex XMLs that have a namespace, we use Mule Namespace Manager to set the namespaces in the application.

But what if we have an XML that has dynamic namespace with it??

For example, let’s consider we have an XML with the following namespaces http://www.efg.com/schemas:

Image title

And the we have the same XML with the following namespaces http://www.axyz.com/schemas:

Image title

We can see here the same XML has dynamic namespaces http://www.efg.com/schemas and http://www.axyz.com/schemas. 

So, how can we set our flow such that we can extract the node values from the XML different and dynamic namespaces for the same XML???

Extracting Node Value From XML With Dynamic Namespaces:

Image title

Designing our Mule Flow:

Image title

We can see above that we have set the namespace manager and set both the namespaces there.
We can also see that in our XPATH3 we have used /* to get the value no matter what namespace is set in the XML out of both in the XML.

Our flows look as the above with a graphical view. We have used a logger to get the extracted value using XPATH3:

Image title

Testing Our Application
Image title

Let us consider, we get the above XML as input with the namespace shown above.
When we hit the URL http://localhost:7393/account, we successfully able to extract the value from the nodes in the console using logger with the namespace http://www.axyz.com/schemas.
Image title

For the following XML request:
Image title

Now if we change the namespace in the XML as http://www.efg.com/schemas and
we hit the URL http://localhost:7393/account again, we successfully able to extract the same value from the nodes in the console using logger as below:

Image title

Conclusion…

Here it was a small demonstration of using Namespace Manager with XPATH3 dynamically. We can set any number of namespace here as long the XML structure remains same.

Hope you like this article demonstrating extracting XML node values with dynamic namespaces. Now it's your turn to experiment and provide your feedback on the comments section.

XML

Opinions expressed by DZone contributors are their own.

Related

  • How to Convert XLS to XLSX in Java
  • Thread-Safety Pitfalls in XML Processing
  • Loading XML into MongoDB
  • SmartXML: An Alternative to XPath for Complex XML Files

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!