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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:58:24+00:00 2026-06-15T03:58:24+00:00

I am trying to replicate this XML: <?xml version=1.0?> <AccessRequest xml:lang=en-US> <AccessLicenseNumber>YourLicenseNumber</AccessLicenseNumber> <UserId>YourUserID</UserId> <Password>YourPassword</Password>

  • 0

I am trying to replicate this XML:

<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>YourLicenseNumber</AccessLicenseNumber>
  <UserId>YourUserID</UserId>
  <Password>YourPassword</Password>
</AccessRequest>
<?xml version="1.0"?>
<AddressValidationRequest xml:lang="en-US">
  <Request>
    <TransactionReference>
      <CustomerContext>Your Test Case Summary Description</CustomerContext>
      <XpciVersion>1.0</XpciVersion>
    </TransactionReference>
    <RequestAction>XAV</RequestAction>
    <RequestOption>3</RequestOption>
  </Request>

  <AddressKeyFormat>
    <AddressLine>AIRWAY ROAD SUITE 7</AddressLine>  
    <PoliticalDivision2>SAN DIEGO</PoliticalDivision2>
    <PoliticalDivision1>CA</PoliticalDivision1>
    <PostcodePrimaryLow>92154</PostcodePrimaryLow>
    <CountryCode>US</CountryCode>
  </AddressKeyFormat>
</AddressValidationRequest>

I am using one class to build the request:

  public UpsRequestBuilder()
    {
        try
        {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

            doc = docBuilder.newDocument();
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
    }

    public void accessRequestBuilder(String accessKey, String username, String password)
    {
        Element accessRequest = doc.createElement("AccessRequest");
        doc.appendChild(accessRequest);

        Element license = doc.createElement("AccessLicenseNumber");
        accessRequest.appendChild(license);
        license.setTextContent(accessKey);

        Element userId = doc.createElement("UserId");
        accessRequest.appendChild(userId);
        userId.setTextContent(username);

        Element pass = doc.createElement("Password");
        accessRequest.appendChild(pass);
        pass.setTextContent(password);

        System.out.println("completed Requestbuilder");
    }

    public void addAddress(Address address)
    {
        Element addressKeyFormat = doc.createElement("AddressKeyFormat");
        doc.appendChild(addressKeyFormat);

        Element addressLine = doc.createElement("AddressLine");
        addressKeyFormat.appendChild(addressLine);
        addressLine.setTextContent(address.getState() + ' ' + address.getStreet2());

        Element city = doc.createElement("PoliticalDivision2");
        addressKeyFormat.appendChild(city);
        city.setTextContent(address.getCity());

        Element state = doc.createElement("PoliticalDivision1");
        addressKeyFormat.appendChild(state);
        state.setTextContent(address.getState());

        Element zip = doc.createElement("PostcodePrimaryLow");
        addressKeyFormat.appendChild(zip);
        zip.setTextContent(address.getZip());

        Element country = doc.createElement("CountryCode");
        addressKeyFormat.appendChild(country);
        country.setTextContent(address.getCountry()); 
        System.out.println("completed addAddress");
    }

    public void validateAddressRequest(String customerContextString, String action)
    {

        Element addressValidation = doc.createElement("AddressValidationRequest");
        doc.appendChild(addressValidation);
        Element transactionReference = doc.createElement("TransactionReference");
        addressValidation.appendChild(transactionReference);

        Element customerContext = doc.createElement("CustomerContext");
        Element version = doc.createElement("XpciVersion");
        transactionReference.appendChild(customerContext);
        customerContext.setTextContent(customerContextString); //TODO figure out a way to optionally pass context text
        transactionReference.appendChild(version);
        version.setTextContent("1.0");//change this if the api version changes

        Element requestAction = doc.createElement("RequestAction");
        addressValidation.appendChild(requestAction);
        requestAction.setTextContent(action);
        System.out.println("completed validateAddressRequest");
    }

And this is the function that uses it:

public void validateAddress(Address address)
    {
        UpsRequestBuilder request = new UpsRequestBuilder();
        request.accessRequestBuilder(accessKey, username, password);
        request.validateAddressRequest("", "3");
        request.addAddress(address);

        System.out.println(request.toString());

    }

When I try and print out the XML from this, I get the error “HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.” It happens in the validateAddressRequest function when I try and add the addressValidation element to the document (doc). Here is the exact line:

doc.appendChild(addressValidation);

what is the problem with adding this element to the document?

  • 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-06-15T03:58:25+00:00Added an answer on June 15, 2026 at 3:58 am

    what is the problem with adding this element to the document?

    You’re trying to add it at the top level of the document. You can’t do that, as the document already has a root element. Any XML document can only have a single root element.

    The XML you’ve shown at the top of your question isn’t a single XML document – it’s two.

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

Sidebar

Related Questions

Rookie question, I think. I'm just trying to replicate this: http://rpubs.com/gallery/googleVis Open a new
I've done this before once, I'm trying to replicate what I did so far
This may be a stupid question, but I'm trying to replicate a customer's OpenLDAP
UPDATE: In trying to replicate this problem one more time to answer your questions
first post ever here I'm trying to replicate this sort of JSON object so
ok, so i am trying to replicate this animation at the top of this
I'm trying to replicate this construct: http://kaitnieks.com/images/divme.png The question consists of 2 parts: 1)
I'm trying to replicate this layout with HTML/CSS: http://reformrevolution.com/ I think I'm getting close
I'm trying to replicate this: http://webdesignerwall.com/tutorials/css-gradient-text-effect however I can't seem to get it to
I've been trying to replicate this border for hours without success: Any idea on

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.