1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

jsp/DOM question

Discussion in 'Software Development' started by tovachanah, Feb 12, 2007.

Thread Status:
Not open for further replies.
  1. tovachanah

    tovachanah Thread Starter

    Feb 15, 2006
    i am running a program through jsp and getting the following msg from my programAdding

    new Node to XML message...
    invalid character in name

    the string 'new node to XML message is from the JSP'

    the invalid character in name is from the java program

    (short description of program: add a new node to an xml using DOM
    my program
    import com.skatestown.invoice.InvoiceChecker;

    import java.io.InputStream;

    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;

    import org.w3c.dom.Attr;
    import org.w3c.dom.Element;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;

    * Add a new item node to the SkatesTown invoice using the DOM parser
    public class InvoiceCheckerAdd implements InvoiceChecker {
    * Adds an itme node to the invoice
    * @DueDate: Feb 13, 2007
    * Program will create a new item node, fill the attributes and
    * attach it to the parent (order)
    * @param invoiceXML Invoice XML document
    * @exception Exception Any exception returned during checking
    public void checkInvoice(InputStream invoiceXML) throws Exception {

    // Obtain parser instance and parse the document
    DocumentBuilderFactory factory =
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(invoiceXML);

    // find the order node - the parent of the item
    Node orderNode = doc.getElementsByTagName("order").item(0);

    // create the item node and fill the attributes
    Element itemElement1 = doc.createElement("item");

    // Create and fill attributes of the new node
    Attr idAttr1 = doc.createAttribute("id");

    Attr quantityAttr1 = doc.createAttribute("quantity");

    Attr unitPriceAttr1= doc.createAttribute("unit price");

    // attatch the itemNode to the parent

    // create. fill and attach element item
    Element itemElement2 = doc.createElement("item");

    Attr idAttr2 = doc.createAttribute("id");

    Attr quantityAttr2 = doc.createAttribute("quantity");

    Attr unitPriceAttr2= doc.createAttribute("unit price");


    } //end CheckInvoice

    } //end CheckInvoiceAdd


    what is the invalid name referring to?
  2. Chicon


    Jul 29, 2004
    Hi tovachanah,

    I don't think the attribute unit price is valid as XML doesn't accept tag names including space.
    I suggest you to have a try with unit_price.
  3. tovachanah

    tovachanah Thread Starter

    Feb 15, 2006
    thank you...duh i should have looked at the xml
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/543509

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice