Thursday, February 3, 2011

XML - New Line

I had a heck of time with putting a new line for XML.
Why?


Here is an assignment for the XML class that I was (and still am) taking.


Let’s start with something that we all should know how to do.
Write an XML document and a Cascading Style Sheet (CSS) that will display your name, the date, and the assignment number, all on separate lines.

No kiddin' :O

I didn't have a clue. Searched everywhere, including W3C site, but no one, no where else shows me how to put a new line. There are a lot of discussions about it, but none worked. So, after several hours of agony, this is what I came up with.

CSS File:

body
{
    background-color: #ffffff;
    font-size: medium;
    font-family: Sans-serif;
}
Col
{
     width: 100%;  
}

nameHead, dateHead, assignmentHead
{
    /* clear: left; */
    color: #505050;
    width: 160px;
}
name, date, assignment
{
    color: #505050;
}


XML File:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/css" href="StyleSheet1.css"?>

<body>
  <col>

    <nameHead>
      Name:
    </nameHead>
    <name>
      Tetsuro Hirouji
    </name>
  </col>

  <col>
    <dateHead>
      Date:
    </dateHead>
    <date>
      02/02/2011
    </date>
  </col>

  <col> 
    <assignmentHead>
      Assignment #:
    </assignmentHead>
    <assignment>
      1
    </assignment>
  </col>

</body>

The key is to use a container with 100% width, and put the text inside. I don't know how else to do it.

No comments:

Post a Comment