Re: [xml] xml nobie.. can i use this xml format??



can i use blow xml format in libxml2 ?
        .       .       .
<getinfo>
   <system>
       <cpu1:free> 10</cpu1:free>
       <cpu2:free> 90 </cpu2:free>
     </system>
</getinfo>

Hi, I'm a newbie, too, but this much I can tell you: The colon (':') in a tag name is used to denote a namespace, so you're telling an XML parser that "system" contains an element "free" belonging to a namespace "cpu1" and another kind of "free" belonging to a namespace "cpu2". If you look at it this way:
<getinfo>
  <orchard>
    <appletree:fruit>10</appletree:fruit>
    <orangetree:fruit>90</orangetree:fruit>
  </orchard>
</getinfo>

They're not the same things.

You could use this:
<getinfo>
  <system>
    <free cpu="1">10</free>
    <free cpu="2">90</free>
   </system>
</getinfo>

(in this case, you are using an attribute named "cpu")

or this:
<getinfo>
  <system>
    <cpu>
      <id>1</id>
      <free>10</free>
    </cpu>
    <cpu>
      <id>2</id>
      <free>90</free>
    </cpu>
  </system>
</getinfo>

There are probably other ways to do it, but I would prefer the last example.
--
Bruce A. Johnson
Software Engineer
Blue Ridge Networks
(703) 633-7320 / ext. 233
Ours goes to eleven.


xml-request gnome org wrote:
Send xml mailing list submissions to
        xml gnome org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.gnome.org/mailman/listinfo/xml
or, via email, send a message with subject or body 'help' to
        xml-request gnome org

You can reach the person managing the list at
        xml-owner gnome org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of xml digest..."


Today's Topics:

   1. libxml2 RELAX NG example code (Todd Ditchendorf)
   2. xml nobie.. can i use this xml format?? (YuChan Park)


----------------------------------------------------------------------

Message: 1
Date: Sun, 4 Jun 2006 18:57:14 -0700
From: Todd Ditchendorf <todd ditchnet org>
Subject: [xml] libxml2 RELAX NG example code
To: xml gnome org
Message-ID: <A9302D27-AB71-47A0-995E-D0DBF565E557 ditchnet org>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Can someone please point me to some example code using libxml2's C RELAX NG API? Simple parsing and validating samples would be very helpful.

Thanks!


Todd Ditchendorf

Scandalous Software - Cocoa Developer Tools
http://scan.dalo.us





------------------------------

Message: 2
Date: Mon, 5 Jun 2006 17:25:53 +0900
From: "YuChan Park" <diylinux gmail com>
Subject: [xml] xml nobie.. can i use this xml format??
To: xml gnome org
Message-ID:
        <8e0a9ed10606050125t36fa5d91hc1ca2035ac9a2c1 mail gmail com>
Content-Type: text/plain; charset="iso-8859-1"

Hello everyone.

can i use blow xml format in libxml2 ?

but if i use that xml which load xmlparseMemory then
the problem is occurred in cpu1:free attribute.


----------------------------
<getinfo>
   <system>
       <cpu1:free> 10</cpu1:free>
       <cpu2:free> 90 </cpu2:free>
     </system>
</getinfo>

-----------------------------

and the error message is

-------------------------------------------------------
namespace error : Namespace prefix cpu1 on free is not defined
<getinfo>                       <system>                        <cpu1:free>
1.0</cpu1:free>                      <cpu2:free>1.0</cpu2:free>
                                                                          ^
namespace error : Namespace prefix cpu2 on free is not defined
<getinfo>                       <system>                        <cpu1:free>
1.0</cpu1:free>                      <cpu2:free>1.0</cpu2:free>

-------------------------------------------------------


How can i solve it??


Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnome.org/archives/xml/attachments/20060605/36696b98/attachment.htm

------------------------------

_______________________________________________
xml mailing list
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml


End of xml Digest, Vol 26, Issue 4
**********************************






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]