Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1026807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:08:24+00:00 2026-05-16T12:08:24+00:00

I have the need to parse partial XML fragments (which are presented as std::string),

  • 0

I have the need to parse partial XML fragments (which are presented as std::string), such as this one:

<FOO:node>val</FOO:node>

as xmlDoc objects in libxml2, and because these are fragments, I keep getting the namespace error : Namespace prefix FOO on node is not defined errors spit out into STDERR.

What I am looking for is for either a way to filter just these namespace warnings out or parse the XML fragment straight into a xmlNode object.

I think some sort of hacking around with initGenericErrorDefaultFunc() may be in order to go the first way, but the documentation for libxml2 is absolutely atrocious.

I would frankly prefer to go with the 2nd approach because it would require no error hacking and the node would be already aware of the namespace, but I don’t think it’s possible because the node has to have a root and XML fragments are not guaranteed to have only one root.

I just need some guidance here of how to rid myself of the namespace error warning.

Thank you very much.

  • 1 1 Answer
  • 6 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:08:24+00:00Added an answer on May 16, 2026 at 12:08 pm

    Building on what @Potatoswatter said… can you create a context for the fragments? E.g. concatenate

    <dummyRoot xmlns:FOO="dummy-URI">
    

    in front of your fragment, and

    </dummyRoot>
    

    afterward, then pass the concatenated string to xmlParseMemory().

    Alternatively, why don’t you use xmlParseInNodeContext(), which lets you pass in a node to use as context (including namespaces), and the content can be any Well Balanced Chunk (e.g. multiple elements with no single root element).

    Either method requires that you know, or can scan to find out, the set of all possible namespace prefixes that the fragment may use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string data which I need to parse into a dictionary object.
I have an XML file which I need to parse using PHP and send
I have string as abvd.qweqw.sdfs.a=aqwrwewrwerrew . I need to parse this string and get
I have the following node I need to parse using XSLT 1.0 from xml
I have a string like this that I need to parse into a 2D
I have this website i need to parse for an android app. http://www.wow-coupons.com/rss_online_coupons.xml I
I have this string containing a date I need to parse to get a
I need to parse a string from a datatable into a double. I have
I need to parse a bunch of incoming xml documents, they all have the
I have a large string I need to parse, and I need to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.