Loading ...
Sorry, an error occurred while loading the content.

4358Re: [soaplite] Hash data with complex XML from .Net server

Expand Messages
  • Duncan Cameron
    Jan 23, 2005
    • 0 Attachment
      On 2005-01-23 at 16:52:38 oldfic4 wrote:

      >I'm feeling very dim ( I would have felt much dimmer if it weren't
      >for the help of the people who responded to my previous post -
      >thanks): I'm consuming a service from a .net server. The sml is
      >returned in a hash. I can access elements within the xml using:
      >print $result->valueof('//*/PortalId'), "\n";
      >this works fine as does:
      >my @nodes = $result->valueof('//*/Instruction');
      >foreach $node (@nodes){
      > print "Portal Id: ", $node->{'PortalId'}, "\n";
      >If there's more than 1. But the XML has a number of nested arrays
      >and some of the data I'm trying to extract is contained in
      >attributes. I've tried:
      >my $som = SOAP::Deserializer->deserialize($result);

      If $result is the same as used in the example above then it is
      already a SOM, so you are now trying to deserialise a perl data
      structure rather than a chunk of XML.

      >my $i = 0;
      >foreach my $a ($som->dataof("//Instruction/*")) {
      > $i++;
      > my $j = 0;
      > foreach my $b ($som->dataof("//contact/[$i]/*")) {
      > $j++;
      > print "Contact Name $j ", $som->dataof("//*/Contact Title
      > }
      >but this just gets "syntax error at line 1, column 0, byte 0 at
      >C:/Perl/site/lib/XML/Parser.pm line 187"
      This confirms that you are not parsing XML.
      >Can anyone help me 1, write out the xml as sent to a .xml file
      >and 2, write out a csv file using the nested elements and attributes
      >from within the serialised $result?

      If you use $soap->outputxml(1) then the result of your call will be
      the raw XML, I think that it will be the SOAP envelope. You can then
      perform whatever further processing you need.

    • Show all 2 messages in this topic