Hi Yixing

 

You can use the XmlCursor to insert attributes. Use the cursor to navigate to the element on which you wish to add the attributes. After that do something like the following:

 

                                    QName attQN = new QName("http://www.w3.org/2001/XMLSchema-instance",

                                                            "noNamespaceSchemaLocation",

                                                            "xsi");

                                    c.insertAttributeWithValue(attQN,

                                        "C:\\Documents and Settings\\User\\Desktop\\r&r.xsd");

 

To get an XmlCursor simply call newCursor() on any XmlObject.

 

I tried this in a test program and both the attribute and namespace declaration were automatically put in as you wish.

 

Cheers,

 

Lawrence

 


From: Yixing Ma [mailto:[EMAIL PROTECTED]
Sent: Friday, August 12, 2005 10:46 AM
To: [email protected]
Subject: newbie need help

 

Hi,

 

I just switched to XMLBeans from JAXB.

 

Now I have a question about writing to a file from XMLBeans.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\User\Desktop\r&r.xsd">

 

 

I want to include

 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\User\Desktop\r&r.xsd"

 

information into the newly created XML file. But don't know how. Anyone can help?

 

Regards,

YODA909

 

 

 

Reply via email to