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 6253779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:03:54+00:00 2026-05-24T14:03:54+00:00

I am having troubles using XMLSlurper to update an XML document. Most things work,

  • 0

I am having troubles using XMLSlurper to update an XML document. Most things work, but in some situations a “find” doesn’t find a Node I just appended (appendNode). The new Node is there at the end of processing, but is not found when I am in the middle of adding children.

I found a post about XMLSlurper that says that finding the new Node requires calling parseText again and/or StreaMarkupBuilder (see below). Really?! That seems so kludgy that I thought I’d verify on SO.

Here is a code snippet. The “find” gets NoChildren even though the Node was just added.

    codeNode.appendNode {   
    'lab:vendorData'() {}
}
vendorNode = codeNode.children().find { it.name() == "vendorData" } 

“appendNode doea not modify the slurped document directly. The edit is applied “on the fly” when the document is written out using StreamingMarkupBuilder.”
http://markmail.org/message/5nmxbhwna7hr5zcq#query:related%3A5nmxbhwna7hr5zcq+page:1+mid:bkdesettsnfnieno+state:results

Why can’t I find my new Node?!

  • 1 1 Answer
  • 0 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-24T14:03:54+00:00Added an answer on May 24, 2026 at 2:03 pm

    This is what I got to work. Is not elegant, but got past “update” problem:

        ...
    codeNode.appendNode {   
        'lab:vendorData'() {}
    }
    //-- must re-slurp to see appended node
    labDoc = new XmlSlurper().parseText(serializeXml(labDoc))
    codeNode = getResultNodeFor( nextResult.getCode() );
    vendorNode = codeNode.children().find { it.name() == "vendorData" }
    ...
    def String serializeXml(GPathResult xml){
    XmlUtil.serialize(new StreamingMarkupBuilder().bind {
            mkp.declareNamespace("lab", "www.myco.com/LabDocument")
            mkp.yield labDoc
      } )
    

    }

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

Sidebar

Related Questions

I'm having some troubles using Session Variables as they are being used as Reference
I'm having some troubles with using the std::sort algorithm here. I was reading that
I'm trying to load up XML/SWF Charts with Yii and having some troubles. As
I am having troubles finding elements in an Xml file using LINQ to XML
I am having some troubles getting some regex to work to remove some text,
I'm having troubles using Blend with my visual studio solution. In Runtime, and compile
I'm having troubles on an ASPX form using two ASP default components; The default
I'm having troubles opening a Unicode file in C++ using fstreams instead of the
I'm having troubles adding an attachment to the mantis using mantis connect. I can
I am having troubles uninstalling a shared win32 SxS assembly using Wix3 on WinXP.

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.