Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an problem in creating xml with the

    <c:condition>
        <a:condition>
            <fieldName>fieldName</fieldName>
            <fieldTest>fieldTest</fieldTest>
            <fieldValues>
                <fieldValue>fieldValue</fieldValue>
            </fieldValues>
        </a:condition>
        <operator>operator</operator>
        <a:condition>
            <fieldName>fieldName</fieldName>
            <fieldTest>fieldTest</fieldTest>
            <fieldValues>
                <fieldValue>fieldValue</fieldValue>
            </fieldValues>
        </a:condition>
    </c:condition>

Above is the xml tag given to me.

I need to create this tag using the JDOM/XML in java.

So I am using

Element complexCondition = new Element("c:condition");

code to create "c:condition" tag.

But I am getting error

org.jdom.IllegalNameException: The name "c:condition" is not legal for JDOM/XML elements: Element names cannot contain colons.

So don't have any idea what is going wrong. As I am new to the xml's and JDOM. Please help me out with this issue.

share|improve this question
1  
See: jdom.org/docs/faq.html#a0250 about the colon. – heikkim Oct 12 '12 at 11:10

1 Answer

c: 

is a namespace prefix. you should create your element with namespace. check the constructor :

Element(java.lang.String name, java.lang.String prefix, java.lang.String uri)
  Creates a new element with the supplied (local) name and a namespace given by the supplied prefix and URI combination.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.