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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:15:57+00:00 2026-05-30T15:15:57+00:00

I serialize array of strings to XML, my output: <MyArray> <anyType xsi:type=xsd:string>testString</anyType> <anyType xsi:type=xsd:string></anyType>

  • 0

I serialize array of strings to XML, my output:

<MyArray>
    <anyType xsi:type="xsd:string">testString</anyType>
    <anyType xsi:type="xsd:string"></anyType> // here is empty string, and I want it in output array
</MyArray>

When I try to deserialize this back to array with XMLPullParser it’s create array only with one string.
Why function next() from XmlPullParser on second string only return START_TAG and END_TAG, without TEXT event?
There is any workaround to get empty string from this xml?

  • 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-30T15:15:58+00:00Added an answer on May 30, 2026 at 3:15 pm

    According to http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html,
    more specifically the nextText() method documentation, you get:

    If current event is START_TAG then if next element is TEXT then
    element content is returned or if next event is END_TAG then empty
    string is returned, otherwise exception is thrown. After calling this
    function successfully parser will be positioned on END_TAG. The
    motivation for this function is to allow to parse consistently both
    empty elements and elements that has non empty content.

    The sample code they provide works well, and I’m currently using in my code something in the lines of:

    mPullParser.nextTag();
    mPullParser.require(XmlPullParser.START_TAG, null, tag);
    final String text = mPullParser.nextText();
    mPullParser.require(XmlPullParser.END_TAG, null, tag);
    

    Which works just fine, regardless it’s an empty string or not. Are you using the org.xmlpull.v1.XmlPullParser library?

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

Sidebar

Related Questions

Is it possible to serialize an object into a string or a byte array
I'm in need to serialize an string that is valid xml to an object.
I have a large 2d array that I serialize and base64_encode and throw into
So I have a large 2d array that i serialize, but when I attempt
I'm trying to serialize a Type object in the following way: Type myType =
I plan to serialize a Django model to XML when it's saved or updated.
Hi I am trying to serialize an array of objects which are derived from
I'm trying to deserialize the following XML output: <?xml version=1.0 encoding=ISO-8859-1?> <Foo> <Val>Data1</Val> </Foo>
If my XML is like this: <Item> <Name>Jerry</Name> <Array> <Item> <Name>Joe</Name> </Item> <Item> <Name>Sam</Name>
I need to pass an array of strings to SQL Server 2005, and so

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.