Hi,
Will the following scripts in the java code(unavailableAgencyName = unavailabilityScheduleElement.getChild("OrganizationAgencyName").getText()
work even if I don't reference the namespace prefixes(ns2,ns3,ns4) while getting the value of the element in the xml file?
Thanks,
Tina
---------------------------------------------------
xml file:
---------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:UnavailableSchedules xmlns:ns1=" xmlns:ns2=" xmlns:ns3=" xmlns:ns4=" <ns2:UnavailableSchedule ReasonCode="M">
<ns2:OrganizationAgencyName>Orange County PD</ns2:OrganizationAgencyName>
<ns3:OrganizationBranchName>Newport Beach</ns3:OrganizationBranchName>
<ns3:IdentificationID>bfleck</ns3:IdentificationID>
<ns3ersonGivenName>Bela</ns3ersonGivenName>
<ns3ersonMiddleName>Anton</ns3ersonMiddleName>
<ns3ersonSurName>Fleck</ns3ersonSurName>
<ns2:StartDate>2008-05-26-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-01-07:00</ns2:EndDate>
</ns2:UnavailableSchedule>
<ns2:UnavailableSchedule ReasonCode="T">
<ns2:OrganizationAgencyName>Orange County PD</ns2:OrganizationAgencyName>
<ns3:OrganizationBranchName>Newport Beach</ns3:OrganizationBranchName>
<ns3:IdentificationID>opeterson</ns3:IdentificationID>
<ns3ersonGivenName>Oscar</ns3ersonGivenName>
<ns3ersonMiddleName></ns3ersonMiddleName>
<ns3ersonSurName>Peterson</ns3ersonSurName>
<ns2:StartDate>2008-06-02-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-08-07:00</ns2:EndDate>
</ns2:UnavailableSchedule>
</ns2:UnavailableSchedules>
---------------------------------------------
java file:
--------
import java.net.URL;
import org.jdom.* ;
import org.jdom.input.*;
import org.jdom.output.* ;
import java.util.*;
import java.io.*;
Document doc = builder.build(...);
Element root = doc.getRootElement();
List unavailableScheduleChildren = root.getChildren();
Iterator unavailableScheduleElements = unavailableScheduleChildren.iterator();
while(unavailableScheduleElements.hasNext())
{
Element unavailabilityScheduleElement = (Element)unavailableScheduleElements.next();
unavailableReasonCode=unavailabilityScheduleElement.getAttributeValue("ReasonCode");
unavailableAgencyName = unavailabilityScheduleElement.getChild("OrganizationAgencyName").getText() ;
unavailableBranchName = unavailabilityScheduleElement.getChild("OrganizationBranchName").getText() ;
}
Will the following scripts in the java code(unavailableAgencyName = unavailabilityScheduleElement.getChild("OrganizationAgencyName").getText()
work even if I don't reference the namespace prefixes(ns2,ns3,ns4) while getting the value of the element in the xml file?
Thanks,
Tina
---------------------------------------------------
xml file:
---------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:UnavailableSchedules xmlns:ns1=" xmlns:ns2=" xmlns:ns3=" xmlns:ns4=" <ns2:UnavailableSchedule ReasonCode="M">
<ns2:OrganizationAgencyName>Orange County PD</ns2:OrganizationAgencyName>
<ns3:OrganizationBranchName>Newport Beach</ns3:OrganizationBranchName>
<ns3:IdentificationID>bfleck</ns3:IdentificationID>
<ns3ersonGivenName>Bela</ns3ersonGivenName>
<ns3ersonMiddleName>Anton</ns3ersonMiddleName>
<ns3ersonSurName>Fleck</ns3ersonSurName>
<ns2:StartDate>2008-05-26-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-01-07:00</ns2:EndDate>
</ns2:UnavailableSchedule>
<ns2:UnavailableSchedule ReasonCode="T">
<ns2:OrganizationAgencyName>Orange County PD</ns2:OrganizationAgencyName>
<ns3:OrganizationBranchName>Newport Beach</ns3:OrganizationBranchName>
<ns3:IdentificationID>opeterson</ns3:IdentificationID>
<ns3ersonGivenName>Oscar</ns3ersonGivenName>
<ns3ersonMiddleName></ns3ersonMiddleName>
<ns3ersonSurName>Peterson</ns3ersonSurName>
<ns2:StartDate>2008-06-02-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-08-07:00</ns2:EndDate>
</ns2:UnavailableSchedule>
</ns2:UnavailableSchedules>
---------------------------------------------
java file:
--------
import java.net.URL;
import org.jdom.* ;
import org.jdom.input.*;
import org.jdom.output.* ;
import java.util.*;
import java.io.*;
Document doc = builder.build(...);
Element root = doc.getRootElement();
List unavailableScheduleChildren = root.getChildren();
Iterator unavailableScheduleElements = unavailableScheduleChildren.iterator();
while(unavailableScheduleElements.hasNext())
{
Element unavailabilityScheduleElement = (Element)unavailableScheduleElements.next();
unavailableReasonCode=unavailabilityScheduleElement.getAttributeValue("ReasonCode");
unavailableAgencyName = unavailabilityScheduleElement.getChild("OrganizationAgencyName").getText() ;
unavailableBranchName = unavailabilityScheduleElement.getChild("OrganizationBranchName").getText() ;
}