in reply to Re: Building XML with tab delimited
in thread Building XML with tab delimited

Thank you very much for the effort. Once thing I noticed is it matters where I place the line "my $report = $doc->createElement("REPORT");" if I placed it outside the while loop and then remove the "else" to replace it with the statement "if ($person_pin eq $copy_person_pin)" then all my 'CHARGE' tag start appearing in the XML but then the XML struct is altered. I am beginning to believe XML:LibXML is very funky.

Replies are listed 'Best First'.
Re^3: Building XML with tab delimited
by Marshall (Canon) on Aug 11, 2016 at 04:41 UTC
    This is actually a very normal thing. I saw the comment in the code. You cannot "sometimes" and "sometimes not" create a "my" variable in some conditional statement and expect that variable will around for use elsewhere. If you do that, you will only have use of it during that "if" clause only. If you violate that, then I think the results are undefined and unpredictable. Maybe I didn't understand what you meant here. This is a very complex module and I don't see the problem and admit such.
Re^3: Building XML with tab delimited
by robby_dobby (Hermit) on Aug 11, 2016 at 05:02 UTC
    Hello sannag,

    Marshall's helpful debugging should have gotten you closer, at least. :-) That said, do note that XML::LibXML has lots of backward compatibility interfaces and it's fairly complex to work with. There's one small change that can help your case:

    In your buildXMLElements sub call, you're passing in the parent element directly as it is and appending child elements into it. If you pass in a ref to it instead, you can see your <CHARGE> elements appear.

    HTH. Good luck and have fun!