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

  • Home
  • SEARCH
  • 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 6041959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:44:13+00:00 2026-05-23T06:44:13+00:00

I am new to c++/parsing, I convert the xsd file into an auto generated

  • 0

I am new to c++/parsing, I convert the xsd file into an auto generated cpp and header file. When I try to access the element (member functions) of the xml file (xmlfilename) I am getting the error “Primary-expression missing before’->’ token”.

My code:

#include "IMACSMsgHeaderType.h"
#include<iostream>
#include<string>
#include <memory>

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>

using namespace std;
using namespace SelfTest;

int main()
  {
 try{
   ::std::auto_ptr< ::SelfTest::MH > xsd (::SelfTest::MH_ ("bala.xml",::xml_schema::flags::dont_validate));
}
catch(const xml_schema::exception& e)
{
    cerr<<e.what()<<endl;        
}
cout<<xsd->n();
return 1;
}

complier output:

vmware@LSS01:~/Desktop/private> make
g++ -c test_classParsing.cpp 
test_classParsing.cpp: In function ‘int main()’:
test_classParsing.cpp:26: error: expected primary-expression before ‘->’ token
make: *** [.o] Error 1

Can anyone explain what is the Primary expression error? and how can I solve this?

More details:

  #include <memory>    
  #include <algorithm> 
  #include <xsd/cxx/tree/exceptions.hxx>
  #include <xsd/cxx/tree/elements.hxx>
  #include <xsd/cxx/tree/containers.hxx>
  #include <xsd/cxx/tree/list.hxx>
  #include <xsd/cxx/xml/dom/parsing-header.hxx>
  #include "IMACSTypes.h"

 #include<iosfwd>
 #include<xercesc/dom/DOMDocument.hpp>
 #include<xercesc/dom/DOMErrorHandler.hpp>
 #include<xercesc/framework/XMLFormatter.hpp>
 #include<xsd/cxx/xml/dom/auto-ptr.hxx>

 namespace SelfTest
 {
    class MH: public ::xml_schema::type
   {
     public:
   // hdrSize
    // 
    typedef ::xml_schema::unsigned_int hdrSize_type;
    typedef ::xsd::cxx::tree::optional< hdrSize_type > hdrSize_optional;
    typedef ::xsd::cxx::tree::traits< hdrSize_type, char > hdrSize_traits;

const hdrSize_optional&
hdrSize () const;

hdrSize_optional&
hdrSize ();

void
hdrSize (const hdrSize_type& x);

void
hdrSize (const hdrSize_optional& x);

// a
// 
typedef ::SelfTest::MessageIDType a_type;
typedef ::xsd::cxx::tree::traits< a_type, char > a_traits;

const a_type&
a () const;

a_type&
a ();

void
a (const a_type& x);

void
a (::std::auto_ptr< a_type > p);

// b
// 
typedef ::SelfTest::DestinationType b_type;
typedef ::xsd::cxx::tree::traits< b_type, char > b_traits;

const b_type&
b () const;

b_type&
b ();

void
b (const b_type& x);

void
b (::std::auto_ptr< b_type > p);

// n
// 
typedef ::xml_schema::string n_type;
typedef ::xsd::cxx::tree::traits< n_type, char > n_traits;

const n_type&
n () const;

n_type&
n ();

void
n (const n_type& x);

void
n (::std::auto_ptr< n_type > p);
// Constructors.

MH (const a_type&,
    const b_type&,
    const n_type&,
   );

MH (const ::xercesc::DOMElement& e,
    ::xml_schema::flags f = 0,
    ::xml_schema::container* c = 0);

MH (const MH& x,
    ::xml_schema::flags f = 0,
    ::xml_schema::container* c = 0);

virtual MH*
_clone (::xml_schema::flags f = 0,
        ::xml_schema::container* c = 0) const;

virtual 
~MH ();

// Implementation.
//
protected:
void
parse (::xsd::cxx::xml::dom::parser< char >&,
       ::xml_schema::flags);

protected:
hdrSize_optional hdrSize_;
::xsd::cxx::tree::one< a_type > a_;
::xsd::cxx::tree::one< b_type > b_;
::xsd::cxx::tree::one< n_type > n_;
 };

  ::std::auto_ptr< ::SelfTest::MH >
   MH_ (const ::std::string& uri, ::xml_schema::flags f = 0,const ::xml_schema::properties& p = ::xml_schema::properties ());

}

i have no idea where i am wrong pls some one guide me..Thanks in advance

  • 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-23T06:44:14+00:00Added an answer on May 23, 2026 at 6:44 am

    Your xsd goes out of scope when you leave the try block. Try moving the cout into try like this:

    int main()
    {
        try
        {
          std::auto_ptr< SelfTest::MH > 
          xsd( SelfTest::MH_("bala.xml", xml_schema::flags::dont_validate) );
          cout << xsd->n();
        }
        catch(const xml_schema::exception& e)
        {
            cerr << e.what() << endl;        
        }
    
        return 0;
    }
    

    The operations of auto_ptr are guaranteed not to throw. So alternatively you can do this as well if you want to limit the scope of your try block:

    int main()
    {
        std::auto_ptr< SelfTest::MH > xsd;
        try
        {
          xsd.reset( SelfTest::MH_("bala.xml", xml_schema::flags::dont_validate) );
        }
        catch(const xml_schema::exception& e)
        {
            cerr << e.what() << endl;        
        }
        if( xsd.get() )
          cout << xsd->n();
    
        return 0;
    }
    

    Note, your main should return 0 if there’s no error.

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

Sidebar

Related Questions

I'm new to XML parsing and want to convert XML file resulting from a
I'm new to DOM parsing in PHP: I have a HTML file that I'm
I am parsing a string to convert it into a DateTime. I am getting
I'm trying to convert CSV data into paring array data, but I'm totally new
Possible Duplicate: Converting ereg expressions to preg I am totally new to parsing a
still new to XML parsing with the iphone so i have a few questions.
I am new to xml parsing. I have the following xml <myMainList> <mySubList> <edited>true</edited>
I am new in android and i want to do parsing through api and
I'm parsing an email using the below style message = Mail.new(body) #where body is
I am new to iPhone development. I am parsing a URL and displayed its

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.