Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I want to process tree-structured data which is not XML but can easily be converted into XML. I want to make this conversion on the fly, creating XML nodes and adding them to the in-memory structure. Then, I want to use XPath expressions to access several nodes, modify them, and write the whole thing out into an XML file.

I read several XML::* manpages, and even the 'Perl&XML' book, but cannot find a place to start with. I was imagining something like my $tree = XML::some_class->new; my $new_node = $tree->new_node('node_tag', 'node_text'); $known_node->add_child($new_node), and then feeding $tree into an XML::XPath instance. Or, I might consider generating SAX events while reading my data source which would magically create the data structure in memory.

In fact, I already wrote code which creates a tree-like structure in memory, so it would be easy to turn it into a data structure which XML::XPath understands, but I cannot find the spec of what is required on XPath's side.

Almost everything I've found so far concentrates on parsing XML files, or on writing handlers for SAX events. What I found on SAX drivers was not too instructive either. A code sample would be great, but a link to further reading will do.


In reply to How to create XML tree from non-XML source by H4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-12-07 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?