Re: Help with accessing an unknown set of data generated by XML::Simple

"Christopher R. Maden" <[email protected]> Fri, 17 Feb 2012 23:50:54 -0500
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
On 02/17/2012 09:35 PM, Dale Puckett wrote:
> Additional Clarification:
> 
>>From the section of the XML Sample attached earlier that reads:
> 
> <TEMPWEBFORMTEXT><![CDATA[webtag:ALL_AD_TEXT]]></TEMPWEBFORMTEXT>
> 		<TEMPRAWTEXT><![CDATA[addquery:rawText]]></TEMPRAWTEXT>
> 		<PUBID>db:pubID</PUBID>
> 		<ACCTID>db:accountID</ACCTID>
> 		
> I would like to see an array or hash that contains:
> 
> "TEMPWEBFORMTEXT", "webtag:ALL_AD_TEXT"
> "TEMPRAWTEXT", "addquery:rawText"
> "PUBID", "db:pubID"
> "ACCTID", "db:accountID"
> And, maybe:
> 
> "Jobs:, ""
> 
> If I could get these data pairs I have the support code to finish the rest
> of he project.

Presumably there is a wrapper around those elements.  (If there is not,
then it is not an XML document...)

Your key-and-value pairs are actually just element type names and
content.  From the wrapper element, you could iterate over the child
elements and get their name and content.  Construct key-value pairs from
those if you need to, or just act on them as you find them.

You are not going to get that last pair without doing some validation
against a schema and checking for non-existence of optional elements.
XML does not really have a concept of not-present elements.

~Chris
-- 
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“Be wary of great leaders.  Hope that there are many, many small
 leaders.” — Pete Seeger
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs