dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML exam question for you guru's

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Posts
    7

    XML exam question for you guru's

    Hi

    A friend has passed this to me to see if i could help. My knowledge of xml is limited but can anyone help?

    1. Write an XML document that marks up the following data:

    Name Job Department Cubicle
    Joe Programmer Engineering 5E
    Erin Designer Marketing 9M
    Melissa Designer Human Resources 8H
    Craig Administrator Engineering 4E
    Danielle Programmer Engineering 12E
    Frank Salesperson Marketing 17M
    Corinne Programmer Technical Support 19T

    Easy. Done that.



    2.Modify the XML document of 1 to qualify each person with a namespace prefix corresponding to their job. Need help on this one.

    and lastly:

    3. Write Javascript code that uses DOM1 to replace every job description that matches
    "Programmer" with "Developer".


    Any help REALLY appreciated dudes. Many thanks for your time.

    Chris
    Last edited by thegown; 04-30-2003 at 07:39 AM.

  2. #2
    Member
    Join Date
    Jan 2003
    Location
    Australia, Adelaide (SA)
    Posts
    97
    I've made the assumption that the list you gave was a list of Employees.

    Answer 1:
    PHP Code:
    <employees>
      <
    employee name="Joe" job="Programmer" department="Engineering" cubicle="5E" />
      <
    employee name="Erin" job="Designer" department="Marketing" cubicle="9M" />
      <
    employee name="Melissa" job="Designer" department="Human Resources" cubicle="8H" />
      <
    employee name="Craig" job="Administrator" department="Engineering" cubicle="4E" />
      <
    employee name="Danielle" job="Programmer" department="Engineering" cubicle="12E" />
      <
    employee name="Frank" job="Salesperson" department="Marketing" cubicle="17M" />
      <
    employee name="Corinne" job="Programmer" department="Technical Support" cubicle="19T" />
    </
    employees
    Answer 2:
    PHP Code:
    <employees
     xmlns
    :p="http://mycompany.com/schemas/employees/Programmer"
     
    xmlns:d="http://mycompany.com/schemas/employees/Designer"
     
    xmlns:a="http://mycompany.com/schemas/employees/Administrator"
     
    xmlns:s="http://mycompany.com/schemas/employees/Salesperson"
    >
      <
    p:employee name="Joe" job="Programmer" department="Engineering" cubicle="5E" />
      <
    d:employee name="Erin" job="Designer" department="Marketing" cubicle="9M" />
      <
    d:employee name="Melissa" job="Designer" department="Human Resources" cubicle="8H" />
      <
    a:employee name="Craig" job="Administrator" department="Engineering" cubicle="4E" />
      <
    p:employee name="Danielle" job="Programmer" department="Engineering" cubicle="12E" />
      <
    s:employee name="Frank" job="Salesperson" department="Marketing" cubicle="17M" />
      <
    p:employee name="Corinne" job="Programmer" department="Technical Support" cubicle="19T" />
    </
    employees
    Answer 3:
    PHP Code:
    // assumes xmlEmployees refers to the above XML
    var programmerNodeList xmlEmployees.documentElement.getElementsByTagName("p:employee");
    for( var 
    0programmerNodeList.lengthi++ )
    {
      
    programmerNodeList[i].setAttribute("job""Developer");

    Tim Walters
    Senior Developer
    XML Evangelist
    "XML isn't a language, it's a way of life!"

  3. #3
    Junior Member
    Join Date
    Apr 2001
    Posts
    7
    thankyou so much Tim, that's really helpful, nice one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center