ctaustin has asked for the wisdom of the Perl Monks concerning the following question:
I would like to take part of schema and load it into a<?xml version="1.0" encoding="utf-8" ?>- <xs:schema id="EverNetOffice" + targetNamespace="http://www.nwmls.com/Schemas/General/EverNetOfficeX +ML.xsd" elementFormDefault="qualified" xmlns="http://www.nwmls.com/Sc +hemas/General/EverNetOfficeXML.xsd" xmlns:mstns="http://www.nwmls.com +/Schemas/General/EverNetOfficeXML.xsd" xmlns:xs="http://www.w3.org/20 +01/XMLSchema">- <xs:element name="Office">- <xs:complexType>- <xs:sequence> <xs:element name="NRDSID" type="String11" /> <xs:element name="AssociationId" type="xs:nonNegativeInteger" /> <xs:element name="OfficeType" type="String4" /> <xs:element name="Status" type="String1" />- <xs:element name="Contact" maxOccurs="1" minOccurs="1">- <xs:complexTy +pe>- <xs:sequence> <xs:element name="Email" type="String80" /> <xs:element name="WebAddress" type="String80" /> <xs:element name="OfficeAreaCode" type="xs:nonNegativeInteger" /> <xs:element name="OfficePhone" type="xs:nonNegativeInteger" /> <xs:el +ement name="FaxAreaCode" type="xs:nonNegativeInteger" /> <xs:element name="FaxPhone" type="xs:nonNegativeInteger" /> </xs:sequ +ence> </xs:complexType> </xs:element>- <xs:element name="Address" minOccurs="1">- <xs:complexType>- <xs:sequence> <xs:element name="CareOf" type="String30" /> <xs:element name="Street" type="String30" /> <xs:element name="City" type="String21" /> <xs:element name="State" type="String2" /> <xs:element name="Zip" type="xs:nonNegativeInteger" /> <xs:element na +me="ZipPlus4" type="xs:nonNegativeInteger" /> <xs:element name="Coun +ty" type="String21" /> </xs:sequence>- <xs:attribute name="AddressType">- <xs:simpleType>- <xs:restriction base="xs:string"> <xs:enumeration value="Street" /> <xs:enumeration value="Mailing" /> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element>- <xs:simpleType name="String11">- <xs:restriction base="xs:string"> <xs:maxLength value="11" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String4">- <xs:restriction base="xs:string"> <xs:maxLength value="4" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String2">- <xs:restriction base="xs:string"> <xs:maxLength value="2" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String1">- <xs:restriction base="xs:string"> <xs:maxLength value="1" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String80">- <xs:restriction base="xs:string"> <xs:maxLength value="80" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String30">- <xs:restriction base="xs:string"> <xs:maxLength value="30" /> </xs:restriction> </xs:simpleType>- <xs:simpleType name="String21">- <xs:restriction base="xs:string"> <xs:maxLength value="21" /> </xs:restriction> </xs:simpleType> </xs:schema>
I am tyring to figure out XML::XPath as way to do this. I am guessing that I need to ->find('//Associationid')id, phone, fax, city, county, zip
This is causing the following error:my $xp=XML::XPath->new(filename=>$file); my $hash; my $id=$xp->find('//Associationid'); my $phone->find('//OfficePhone'); ... ... if ($id->get_nodelist){ $hash{$id}{$phone}{$fax}{$county}{$zip}; }
Is this even the best approach? How about the next xmlCan't call method "get_nodelist" on an undefined value
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: loading xml into mysql
by Chady (Priest) on Dec 17, 2004 at 07:52 UTC | |
Re: loading xml into mysql
by Anonymous Monk on Dec 17, 2004 at 03:44 UTC | |
Re: loading xml into mysql
by dakkar (Hermit) on Dec 17, 2004 at 15:24 UTC |