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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:33:11+00:00 2026-06-12T15:33:11+00:00

Is it possible to get XML::LibXML to parse the node shown in the example

  • 0

Is it possible to get XML::LibXML to parse the node shown in the example below? I realize I may be creating invalid XML by specifying a '*' as part of the node name and would appreciate it if someone could explain why it is invalid:

use strict;
use warnings;
use XML::LibXML;

my $doc = XML::LibXML->createDocument;

my $quirky = XML::LibXML::Element->new( 'YAK*' );
$quirky->appendText( 'Important Data' );

$doc->setDocumentElement( $quirky );

print $doc->toString;  # <?xml version="1.0"?>
                       # <YAK*>Important Data</YAK*>

my $data = XML::LibXML
           ->new
             ->parse_string( $doc->toString );

Output:

<?xml version="1.0"?>
<YAK*>Important Data</YAK*>
:2: parser error : error parsing attribute name
<YAK*>Important Data</YAK*>
    ^
:2: parser error : attributes construct error
<YAK*>Important Data</YAK*>
    ^
:2: parser error : Couldn't find end of Start Tag YAK line 2
<YAK*>Important Data</YAK*>
    ^
:2: parser error : Extra content at the end of the document
<YAK*>Important Data</YAK*>
    ^
  • 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-12T15:33:12+00:00Added an answer on June 12, 2026 at 3:33 pm

    It will attempt work if you turn on a recover option–

    my $parser = XML::LibXML->new;
    $parser->recover_silently(1);
    my $doc2 = $parser->parse_string( $doc->toString );
    print $doc2->toString;
    

    But, as you see, though it can parse an invalid document it can’t/won’t roundtrip one–

    <?xml version="1.0"?>
    <YAK/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this article , it's possible to get multiline XML comments -- instead
As the title says, is it possible to get hands on the XML representation
In this example I get to times '96'. Is there a possible case where
I'm using vb script and MSXML2.DOMDocument to parse a xml document. Is it possible
Is it possible to get the total number of XML nodes? Also, how does
Is it possible to get an XML file (not HTML) from a server, add/remove/edit
Is it possible to get the XML generated by SOAP Client before sending it
Using simplexml, is it possible to get the children of a node based on
Is it possible to get the zip version of some module (in this example
When requesting an object for example using REST, is it possible to get the

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.