in reply to Element Missing in output XML file?

Anonymous Monk:

I'm not certain I understand your question, and I've never used XML::LibXML, so I may be wildly off base. That said, a cursory examination suggests that your problem is with this line:

 for my $para ($document->getElementsByTagName ("p")){

I suspect that getElementsByTagName doesn't find any paragraph elements for the cases indicated, so your code skips the entire for loop body. It's hard to be sure, though, as you forgot to show us some test data to check against.

...roboticus

Replies are listed 'Best First'.
Re^2: Element Missing in output XML file?
by Anonymous Monk on Mar 11, 2008 at 17:25 UTC

    Thank you for your reply.

    But I wonder why I get part of the output missing.....by the way, can you suggest any stable XML creator?

      Again ... you don't provide any sample data for input, and your code isn't complete, so I don't have much to go on.

      Looking again at your output, it appears that you're probably executing the original code fragment in a loop over a set of files. If so, I'd suspect that 0.xml has a "p" element in it, while 10.xml doesn't....

      As regards to an XML creator: Sorry--I don't use it, so I couldn't advise anyone about good packages to use.

      A super search on that topic would probably give you some good leads, though.

      ...roboticus

        Thank for your reply. The original code is very long and scatter (I write in rush), so I need more time to come out with a smaller and clear version for you if you willing to help.