5 Replies Latest reply: Jun 20, 2011 8:59 PM by 869899 RSS

    XML

    865392
      hi every one .......i have one problem , i want to create xml where node name is integer value like
      <root>
      <123>java</123>
      <124>basic java</124>
      <125>Tmh</125>
      </root>

      but it gives error "Invalid character in xml "

      if there is any way to create the xml like above then please suggest me. I am very thank full to u.
        • 1. Re: XML
          gimbal2
          "it gives error"

          What exactly is "it"? There are a 101 ways to create XML files. The most simple is simply opening a FileWriter / PrintStream and writing it out as pure text. You won't ever run into problems that way.
          • 2. Re: XML
            DrClap
            When you describe that file as "XML" you are making an error. XML does not permit element names to begin with a digit. So yes, you can certainly create such a file by writing it as text. But don't make the mistake of describing it as an XML document. It isn't. And if you give it to somebody else to parse as XML, they aren't going to be happy with you.
            • 3. Re: XML
              EJP
              You won't ever run into problems that way.
              You may or may not run into problems creating the file, but the next user of the file almost certainly will.
              • 4. Re: XML
                jtahlborn
                EJP wrote:
                You won't ever run into problems that way.
                You may or may not run into problems creating the file, but the next user of the file almost certainly will.
                +1. this is the number 1 way to create broken xml. number 2 is treating encoded xml data like string data.
                • 5. Re: XML
                  869899
                  There is no way to do what you want. Xml may not have numbers for node names.

                  It's difficult to see what you're trying to do but I'd suggest you organise it differently.
                  Something like this:

                  <root>
                  <node>
                  <id>123</id>
                  <name>java</name>
                  </node>
                  <node>
                  <id>124</id>
                  <name>java basic</name>
                  </node>
                  <node>
                  <id>125</id>
                  <name>Thm</name>
                  </node>
                  </root>

                  This scheme allows you to select all names, all ids or all nodes easily