Remove the namespace from XML

Source: Internet
Author: User

Sometimes XML contains namespaces that make XML operations inconvenient. You can remove the built-in functions of the XML class using the following method:

Removenamespace (NS: namespace
): XML


Delete the specified namespace of the object and all its sub-levels. If the namespace is referenced by the qualified name of the object or the qualified name of the object property 
Removenamespaces ()
 
Method does not delete the namespace.


Example:

VaR XML: xml =
<RDF: RDF xmlns: RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns"
Xmlns: DC = "http://purl.org/dc/elements/1.1"
Xmlns = "http://purl.org/rss/1.0/">
<! --... -->
</RDF: RDF>;

Trace (XML. namespacedeclarations (). Length); // 3

Trace (XML. namespacedeclarations () [0] is string );//

VaR DC: namespace = xml. namespace ("DC ");

XML. removenamespace (DC );

Trace (XML. namespacedeclarations (). Length); // 2




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.