Add XmlNode

Here I have the definition of an XmlNode which is a property (PayPreference) 
on my Customer class containing an enum describing how the customer will 
pay.

<PayPerference xsi:type="a4:Customer+CustomerPayOptions" 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">cash</PayPerference>

I now want to add this XmlNode to a different Xml file where the Customer 
class has not defined a PayPreference property.  I get as far as locating 
the parent XmlNode (Customer).  Now I just need to add the XmlNode defined 
above.  To do this, I understand that I need to ask the XmlDocument to 
create the node first before I ask the Customer node to 'AppendChild'.  I 
notice 3 overloads of CreateElement on the XmlDocument to do this:

    CreateElement(string name)
    CreateElement(string qualifiedName, string namespaceURI)
    CreateElement(string prefix, string localName, string namespaceURI)

So now I'm stuck as to what I need to do now.  Any help would be 
appreciated!








0
paul419 (11)
10/26/2005 6:29:29 PM
dotnet.xml 7266 articles. 0 followers. Follow

5 Replies
603 Views

Similar Articles

[PageSpeed] 16

Hi Paul,

Welcome to MSDN newsgroup.
Regarding the adding XmlNode into XmlDocument question you mentioned, we 
can just use the XmlDocument.CreateElement to create a Element xml node and 
then locate the parent node where we want to append the new element. Then, 
we can use the XmlElement(XmlNode) 's AppendChild method to add the new 
element.  Also, in your scenario, your element has some additional 
namespace declaration attributes, we need to append them into the new 
element or in the document also. here is a simple example on creating a new 
xmlelement and add into a existing xmldoument:

the original document is like:

=================
<?xml version="1.0" encoding="utf-8" ?>
<root xmlns="http://www.mytest.org">
	<datas>
		<data id="1">
			<item>fsfdsfs</item>
		</data>
		<data id="2">
			<item>fksfjkdsjfdks</item>
		</data>
	</datas>
</root>
===================

the code that modify the document is:
====================
static void RunXmlDoc()
		{
			XmlDocument doc = new XmlDocument();
			doc.Load(@"..\..\testxml.xml");
			
			XmlElement elm = doc.CreateElement("PayPerference");

			elm.InnerText = "cash";

			
			XmlAttribute nsattr = null;

			nsattr = 
doc.CreateAttribute("xmlns","xsi","http://www.w3.org/2000/xmlns/");
			nsattr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";

			elm.Attributes.Append(
				nsattr
				);

//			
			nsattr = 
doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
			nsattr.InnerText = 
"http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";

			elm.Attributes.Append(
				nsattr
				);


			nsattr = 
doc.CreateAttribute("xsi","type","http://www.w3.org/2001/XMLSchema-instance"
);
			nsattr.InnerText = "a4:Customer+CustomerPayOptions";
			elm.Attributes.Append(
				nsattr
				);

			XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
			manager.AddNamespace("ns1","http://www.mytest.org");

			XmlElement datas = doc.SelectSingleNode("/ns1:root/ns1:datas",manager) 
as XmlElement;

			datas.AppendChild(elm);

			

			Console.WriteLine(doc.OuterXml);

			doc.Save("output.xml");

		}
===========================

The output.xml will be something like;

========================
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.mytest.org">
  <datas>
    <data id="1">
      <item>fsfdsfs</item>
    </data>
    <data id="2">
      <item>fksfjkdsjfdks</item>
    </data>
    <PayPerference xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
%3Dnull" xsi:type="a4:Customer+CustomerPayOptions" 
xmlns="">cash</PayPerference>
  </datas>
</root>
============================

Also, you can find the the "PayPerference" element in the output has an 
empty default namespace 

xmlns=""

you can explicitly specify the default namespace by changing the 
XmlElement's construction to below:

XmlElement elm = 
doc.CreateElement("PayPerference","http://www.mycustomapp.com");

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no 
rights.)





--------------------
| From: "Paul" <paul419@community.nospam>
| Subject: Add XmlNode
| Date: Wed, 26 Oct 2005 11:29:29 -0700
| Lines: 28
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9085
| X-Tomcat-NG: microsoft.public.dotnet.xml
| 
| Here I have the definition of an XmlNode which is a property 
(PayPreference) 
| on my Customer class containing an enum describing how the customer will 
| pay.
| 
| <PayPerference xsi:type="a4:Customer+CustomerPayOptions" 
| 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
%3Dnull">cash</PayPerference>
| 
| I now want to add this XmlNode to a different Xml file where the Customer 
| class has not defined a PayPreference property.  I get as far as locating 
| the parent XmlNode (Customer).  Now I just need to add the XmlNode 
defined 
| above.  To do this, I understand that I need to ask the XmlDocument to 
| create the node first before I ask the Customer node to 'AppendChild'.  I 
| notice 3 overloads of CreateElement on the XmlDocument to do this:
| 
|     CreateElement(string name)
|     CreateElement(string qualifiedName, string namespaceURI)
|     CreateElement(string prefix, string localName, string namespaceURI)
| 
| So now I'm stuck as to what I need to do now.  Any help would be 
| appreciated!
| 
| 
| 
| 
| 
| 
| 
| 
| 

0
stcheng1 (64)
10/27/2005 4:27:10 AM
Hello Steven and thank you for your reply!!

Your solution worked well and it seems that
the part I was missing was that I needed to ask
the document to create the new XmlAttribute and not
the newly created node.

I do have a followup question.  In your solution you hard-
code the namespace prefix 'a4' as follows:

    doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
    nsattr.InnerText =
    "http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
    n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";


But what if I don't know what the prefix is?  It seems that I should ask the 
document
to generate a new one for me if one doesn't already exist.  But on 
XmlDocument I only
see:

    GetPrefixOfNamespace  and
    GetNamespaceOfPrefix

Paul



"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message 
news:z%23EN%236q2FHA.1144@TK2MSFTNGXA01.phx.gbl...
> Hi Paul,
>
> Welcome to MSDN newsgroup.
> Regarding the adding XmlNode into XmlDocument question you mentioned, we
> can just use the XmlDocument.CreateElement to create a Element xml node 
> and
> then locate the parent node where we want to append the new element. Then,
> we can use the XmlElement(XmlNode) 's AppendChild method to add the new
> element.  Also, in your scenario, your element has some additional
> namespace declaration attributes, we need to append them into the new
> element or in the document also. here is a simple example on creating a 
> new
> xmlelement and add into a existing xmldoument:
>
> the original document is like:
>
> =================
> <?xml version="1.0" encoding="utf-8" ?>
> <root xmlns="http://www.mytest.org">
> <datas>
> <data id="1">
> <item>fsfdsfs</item>
> </data>
> <data id="2">
> <item>fksfjkdsjfdks</item>
> </data>
> </datas>
> </root>
> ===================
>
> the code that modify the document is:
> ====================
> static void RunXmlDoc()
> {
> XmlDocument doc = new XmlDocument();
> doc.Load(@"..\..\testxml.xml");
>
> XmlElement elm = doc.CreateElement("PayPerference");
>
> elm.InnerText = "cash";
>
>
> XmlAttribute nsattr = null;
>
> nsattr =
> doc.CreateAttribute("xmlns","xsi","http://www.w3.org/2000/xmlns/");
> nsattr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
>
> elm.Attributes.Append(
> nsattr
> );
>
> //
> nsattr =
> doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
> nsattr.InnerText =
> "http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
> n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
>
> elm.Attributes.Append(
> nsattr
> );
>
>
> nsattr =
> doc.CreateAttribute("xsi","type","http://www.w3.org/2001/XMLSchema-instance"
> );
> nsattr.InnerText = "a4:Customer+CustomerPayOptions";
> elm.Attributes.Append(
> nsattr
> );
>
> XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
> manager.AddNamespace("ns1","http://www.mytest.org");
>
> XmlElement datas = doc.SelectSingleNode("/ns1:root/ns1:datas",manager)
> as XmlElement;
>
> datas.AppendChild(elm);
>
>
>
> Console.WriteLine(doc.OuterXml);
>
> doc.Save("output.xml");
>
> }
> ===========================
>
> The output.xml will be something like;
>
> ========================
> <?xml version="1.0" encoding="utf-8"?>
> <root xmlns="http://www.mytest.org">
>  <datas>
>    <data id="1">
>      <item>fsfdsfs</item>
>    </data>
>    <data id="2">
>      <item>fksfjkdsjfdks</item>
>    </data>
>    <PayPerference xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
> /OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
> %3Dnull" xsi:type="a4:Customer+CustomerPayOptions"
> xmlns="">cash</PayPerference>
>  </datas>
> </root>
> ============================
>
> Also, you can find the the "PayPerference" element in the output has an
> empty default namespace
>
> xmlns=""
>
> you can explicitly specify the default namespace by changing the
> XmlElement's construction to below:
>
> XmlElement elm =
> doc.CreateElement("PayPerference","http://www.mycustomapp.com");
>
> Hope helps. Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
>
> --------------------
> | From: "Paul" <paul419@community.nospam>
> | Subject: Add XmlNode
> | Date: Wed, 26 Oct 2005 11:29:29 -0700
> | Lines: 28
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
> | X-RFC2646: Format=Flowed; Original
> | Message-ID: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.xml
> | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
> | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
> | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9085
> | X-Tomcat-NG: microsoft.public.dotnet.xml
> |
> | Here I have the definition of an XmlNode which is a property
> (PayPreference)
> | on my Customer class containing an enum describing how the customer will
> | pay.
> |
> | <PayPerference xsi:type="a4:Customer+CustomerPayOptions"
> |
> xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
> /OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
> %3Dnull">cash</PayPerference>
> |
> | I now want to add this XmlNode to a different Xml file where the 
> Customer
> | class has not defined a PayPreference property.  I get as far as 
> locating
> | the parent XmlNode (Customer).  Now I just need to add the XmlNode
> defined
> | above.  To do this, I understand that I need to ask the XmlDocument to
> | create the node first before I ask the Customer node to 'AppendChild'. 
> I
> | notice 3 overloads of CreateElement on the XmlDocument to do this:
> |
> |     CreateElement(string name)
> |     CreateElement(string qualifiedName, string namespaceURI)
> |     CreateElement(string prefix, string localName, string namespaceURI)
> |
> | So now I'm stuck as to what I need to do now.  Any help would be
> | appreciated!
> |
> |
> |
> |
> |
> |
> |
> |
> |
> 


0
paul419 (11)
10/27/2005 5:04:59 PM
Thanks for your response Paul,

As for namespace prefix, it doesn't  matter much. Namespace prefix is just 
like an alias of the actual Namespace  URI, so we can choose discretionary 
ones as we like.  And prefix value won't make XML document different as 
long as the Namespace URI is the same between multiple documents.
e.g.

the following xmlelement is identical to each other:
[1]
<ns0:hello  xmlns:ns0="http://www.hello.org" >
<ns0:helloWorld>hello</ns0:helloWorld>
</ns0:hello>

[2]
<ns1:hello xmlns:ns1="http://www.hello.org">
<ns1:helloWorld>hello</ns1:helloWorld>
</ns1:hello>

though the namespace prefix is different( "ns0" and "ns1"), their actual 
Namespace URI are the same. So they're identical.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no 
rights.)



--------------------
| From: "Paul" <paul419@community.nospam>
| References: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl> 
<z#EN#6q2FHA.1144@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Add XmlNode
| Date: Thu, 27 Oct 2005 10:04:59 -0700
| Lines: 222
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OY7ZVix2FHA.3092@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9100
| X-Tomcat-NG: microsoft.public.dotnet.xml
| 
| Hello Steven and thank you for your reply!!
| 
| Your solution worked well and it seems that
| the part I was missing was that I needed to ask
| the document to create the new XmlAttribute and not
| the newly created node.
| 
| I do have a followup question.  In your solution you hard-
| code the namespace prefix 'a4' as follows:
| 
|     doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
|     nsattr.InnerText =
|     
"http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
|     
n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
| 
| 
| But what if I don't know what the prefix is?  It seems that I should ask 
the 
| document
| to generate a new one for me if one doesn't already exist.  But on 
| XmlDocument I only
| see:
| 
|     GetPrefixOfNamespace  and
|     GetNamespaceOfPrefix
| 
| Paul
| 
| 
| 
| "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message 
| news:z%23EN%236q2FHA.1144@TK2MSFTNGXA01.phx.gbl...
| > Hi Paul,
| >
| > Welcome to MSDN newsgroup.
| > Regarding the adding XmlNode into XmlDocument question you mentioned, we
| > can just use the XmlDocument.CreateElement to create a Element xml node 
| > and
| > then locate the parent node where we want to append the new element. 
Then,
| > we can use the XmlElement(XmlNode) 's AppendChild method to add the new
| > element.  Also, in your scenario, your element has some additional
| > namespace declaration attributes, we need to append them into the new
| > element or in the document also. here is a simple example on creating a 
| > new
| > xmlelement and add into a existing xmldoument:
| >
| > the original document is like:
| >
| > =================
| > <?xml version="1.0" encoding="utf-8" ?>
| > <root xmlns="http://www.mytest.org">
| > <datas>
| > <data id="1">
| > <item>fsfdsfs</item>
| > </data>
| > <data id="2">
| > <item>fksfjkdsjfdks</item>
| > </data>
| > </datas>
| > </root>
| > ===================
| >
| > the code that modify the document is:
| > ====================
| > static void RunXmlDoc()
| > {
| > XmlDocument doc = new XmlDocument();
| > doc.Load(@"..\..\testxml.xml");
| >
| > XmlElement elm = doc.CreateElement("PayPerference");
| >
| > elm.InnerText = "cash";
| >
| >
| > XmlAttribute nsattr = null;
| >
| > nsattr =
| > doc.CreateAttribute("xmlns","xsi","http://www.w3.org/2000/xmlns/");
| > nsattr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
| >
| > elm.Attributes.Append(
| > nsattr
| > );
| >
| > //
| > nsattr =
| > doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
| > nsattr.InnerText =
| > 
"http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
| > 
n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
| >
| > elm.Attributes.Append(
| > nsattr
| > );
| >
| >
| > nsattr =
| > 
doc.CreateAttribute("xsi","type","http://www.w3.org/2001/XMLSchema-instance"
| > );
| > nsattr.InnerText = "a4:Customer+CustomerPayOptions";
| > elm.Attributes.Append(
| > nsattr
| > );
| >
| > XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
| > manager.AddNamespace("ns1","http://www.mytest.org");
| >
| > XmlElement datas = doc.SelectSingleNode("/ns1:root/ns1:datas",manager)
| > as XmlElement;
| >
| > datas.AppendChild(elm);
| >
| >
| >
| > Console.WriteLine(doc.OuterXml);
| >
| > doc.Save("output.xml");
| >
| > }
| > ===========================
| >
| > The output.xml will be something like;
| >
| > ========================
| > <?xml version="1.0" encoding="utf-8"?>
| > <root xmlns="http://www.mytest.org">
| >  <datas>
| >    <data id="1">
| >      <item>fsfdsfs</item>
| >    </data>
| >    <data id="2">
| >      <item>fksfjkdsjfdks</item>
| >    </data>
| >    <PayPerference xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| > 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
| > 
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
| > %3Dnull" xsi:type="a4:Customer+CustomerPayOptions"
| > xmlns="">cash</PayPerference>
| >  </datas>
| > </root>
| > ============================
| >
| > Also, you can find the the "PayPerference" element in the output has an
| > empty default namespace
| >
| > xmlns=""
| >
| > you can explicitly specify the default namespace by changing the
| > XmlElement's construction to below:
| >
| > XmlElement elm =
| > doc.CreateElement("PayPerference","http://www.mycustomapp.com");
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Paul" <paul419@community.nospam>
| > | Subject: Add XmlNode
| > | Date: Wed, 26 Oct 2005 11:29:29 -0700
| > | Lines: 28
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.xml
| > | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9085
| > | X-Tomcat-NG: microsoft.public.dotnet.xml
| > |
| > | Here I have the definition of an XmlNode which is a property
| > (PayPreference)
| > | on my Customer class containing an enum describing how the customer 
will
| > | pay.
| > |
| > | <PayPerference xsi:type="a4:Customer+CustomerPayOptions"
| > |
| > 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
| > 
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
| > %3Dnull">cash</PayPerference>
| > |
| > | I now want to add this XmlNode to a different Xml file where the 
| > Customer
| > | class has not defined a PayPreference property.  I get as far as 
| > locating
| > | the parent XmlNode (Customer).  Now I just need to add the XmlNode
| > defined
| > | above.  To do this, I understand that I need to ask the XmlDocument to
| > | create the node first before I ask the Customer node to 
'AppendChild'. 
| > I
| > | notice 3 overloads of CreateElement on the XmlDocument to do this:
| > |
| > |     CreateElement(string name)
| > |     CreateElement(string qualifiedName, string namespaceURI)
| > |     CreateElement(string prefix, string localName, string 
namespaceURI)
| > |
| > | So now I'm stuck as to what I need to do now.  Any help would be
| > | appreciated!
| > |
| > |
| > |
| > |
| > |
| > |
| > |
| > |
| > |
| > 
| 
| 
| 

0
stcheng1 (64)
10/28/2005 1:51:39 AM
Thanks again, Steven.

Based on your response, the approach I'm going to take is to generate the
prefixes myself which I've implemented and it appears to work.

Anyway, your help got me out of a corner, thank you.

Paul

"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message 
news:spDLsI22FHA.1144@TK2MSFTNGXA01.phx.gbl...
> Thanks for your response Paul,
>
> As for namespace prefix, it doesn't  matter much. Namespace prefix is just
> like an alias of the actual Namespace  URI, so we can choose discretionary
> ones as we like.  And prefix value won't make XML document different as
> long as the Namespace URI is the same between multiple documents.
> e.g.
>
> the following xmlelement is identical to each other:
> [1]
> <ns0:hello  xmlns:ns0="http://www.hello.org" >
> <ns0:helloWorld>hello</ns0:helloWorld>
> </ns0:hello>
>
> [2]
> <ns1:hello xmlns:ns1="http://www.hello.org">
> <ns1:helloWorld>hello</ns1:helloWorld>
> </ns1:hello>
>
> though the namespace prefix is different( "ns0" and "ns1"), their actual
> Namespace URI are the same. So they're identical.
>
> Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
> --------------------
> | From: "Paul" <paul419@community.nospam>
> | References: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
> <z#EN#6q2FHA.1144@TK2MSFTNGXA01.phx.gbl>
> | Subject: Re: Add XmlNode
> | Date: Thu, 27 Oct 2005 10:04:59 -0700
> | Lines: 222
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
> | X-RFC2646: Format=Flowed; Original
> | Message-ID: <OY7ZVix2FHA.3092@TK2MSFTNGP10.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.xml
> | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
> | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
> | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9100
> | X-Tomcat-NG: microsoft.public.dotnet.xml
> |
> | Hello Steven and thank you for your reply!!
> |
> | Your solution worked well and it seems that
> | the part I was missing was that I needed to ask
> | the document to create the new XmlAttribute and not
> | the newly created node.
> |
> | I do have a followup question.  In your solution you hard-
> | code the namespace prefix 'a4' as follows:
> |
> |     doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
> |     nsattr.InnerText =
> |
> "http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
> |
> n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
> |
> |
> | But what if I don't know what the prefix is?  It seems that I should ask
> the
> | document
> | to generate a new one for me if one doesn't already exist.  But on
> | XmlDocument I only
> | see:
> |
> |     GetPrefixOfNamespace  and
> |     GetNamespaceOfPrefix
> |
> | Paul
> |
> |
> |
> | "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
> | news:z%23EN%236q2FHA.1144@TK2MSFTNGXA01.phx.gbl...
> | > Hi Paul,
> | >
> | > Welcome to MSDN newsgroup.
> | > Regarding the adding XmlNode into XmlDocument question you mentioned, 
> we
> | > can just use the XmlDocument.CreateElement to create a Element xml 
> node
> | > and
> | > then locate the parent node where we want to append the new element.
> Then,
> | > we can use the XmlElement(XmlNode) 's AppendChild method to add the 
> new
> | > element.  Also, in your scenario, your element has some additional
> | > namespace declaration attributes, we need to append them into the new
> | > element or in the document also. here is a simple example on creating 
> a
> | > new
> | > xmlelement and add into a existing xmldoument:
> | >
> | > the original document is like:
> | >
> | > =================
> | > <?xml version="1.0" encoding="utf-8" ?>
> | > <root xmlns="http://www.mytest.org">
> | > <datas>
> | > <data id="1">
> | > <item>fsfdsfs</item>
> | > </data>
> | > <data id="2">
> | > <item>fksfjkdsjfdks</item>
> | > </data>
> | > </datas>
> | > </root>
> | > ===================
> | >
> | > the code that modify the document is:
> | > ====================
> | > static void RunXmlDoc()
> | > {
> | > XmlDocument doc = new XmlDocument();
> | > doc.Load(@"..\..\testxml.xml");
> | >
> | > XmlElement elm = doc.CreateElement("PayPerference");
> | >
> | > elm.InnerText = "cash";
> | >
> | >
> | > XmlAttribute nsattr = null;
> | >
> | > nsattr =
> | > doc.CreateAttribute("xmlns","xsi","http://www.w3.org/2000/xmlns/");
> | > nsattr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
> | >
> | > elm.Attributes.Append(
> | > nsattr
> | > );
> | >
> | > //
> | > nsattr =
> | > doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
> | > nsattr.InnerText =
> | >
> "http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
> | >
> n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
> | >
> | > elm.Attributes.Append(
> | > nsattr
> | > );
> | >
> | >
> | > nsattr =
> | >
> doc.CreateAttribute("xsi","type","http://www.w3.org/2001/XMLSchema-instance"
> | > );
> | > nsattr.InnerText = "a4:Customer+CustomerPayOptions";
> | > elm.Attributes.Append(
> | > nsattr
> | > );
> | >
> | > XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
> | > manager.AddNamespace("ns1","http://www.mytest.org");
> | >
> | > XmlElement datas = doc.SelectSingleNode("/ns1:root/ns1:datas",manager)
> | > as XmlElement;
> | >
> | > datas.AppendChild(elm);
> | >
> | >
> | >
> | > Console.WriteLine(doc.OuterXml);
> | >
> | > doc.Save("output.xml");
> | >
> | > }
> | > ===========================
> | >
> | > The output.xml will be something like;
> | >
> | > ========================
> | > <?xml version="1.0" encoding="utf-8"?>
> | > <root xmlns="http://www.mytest.org">
> | >  <datas>
> | >    <data id="1">
> | >      <item>fsfdsfs</item>
> | >    </data>
> | >    <data id="2">
> | >      <item>fksfjkdsjfdks</item>
> | >    </data>
> | >    <PayPerference 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> | >
> xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
> | >
> /OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
> | > %3Dnull" xsi:type="a4:Customer+CustomerPayOptions"
> | > xmlns="">cash</PayPerference>
> | >  </datas>
> | > </root>
> | > ============================
> | >
> | > Also, you can find the the "PayPerference" element in the output has 
> an
> | > empty default namespace
> | >
> | > xmlns=""
> | >
> | > you can explicitly specify the default namespace by changing the
> | > XmlElement's construction to below:
> | >
> | > XmlElement elm =
> | > doc.CreateElement("PayPerference","http://www.mycustomapp.com");
> | >
> | > Hope helps. Thanks,
> | >
> | > Steven Cheng
> | > Microsoft Online Support
> | >
> | > Get Secure! www.microsoft.com/security
> | > (This posting is provided "AS IS", with no warranties, and confers no
> | > rights.)
> | >
> | >
> | >
> | >
> | >
> | > --------------------
> | > | From: "Paul" <paul419@community.nospam>
> | > | Subject: Add XmlNode
> | > | Date: Wed, 26 Oct 2005 11:29:29 -0700
> | > | Lines: 28
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
> | > | X-RFC2646: Format=Flowed; Original
> | > | Message-ID: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.xml
> | > | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
> | > | Path: 
> TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
> | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9085
> | > | X-Tomcat-NG: microsoft.public.dotnet.xml
> | > |
> | > | Here I have the definition of an XmlNode which is a property
> | > (PayPreference)
> | > | on my Customer class containing an enum describing how the customer
> will
> | > | pay.
> | > |
> | > | <PayPerference xsi:type="a4:Customer+CustomerPayOptions"
> | > |
> | >
> xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
> | >
> /OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
> | > %3Dnull">cash</PayPerference>
> | > |
> | > | I now want to add this XmlNode to a different Xml file where the
> | > Customer
> | > | class has not defined a PayPreference property.  I get as far as
> | > locating
> | > | the parent XmlNode (Customer).  Now I just need to add the XmlNode
> | > defined
> | > | above.  To do this, I understand that I need to ask the XmlDocument 
> to
> | > | create the node first before I ask the Customer node to
> 'AppendChild'.
> | > I
> | > | notice 3 overloads of CreateElement on the XmlDocument to do this:
> | > |
> | > |     CreateElement(string name)
> | > |     CreateElement(string qualifiedName, string namespaceURI)
> | > |     CreateElement(string prefix, string localName, string
> namespaceURI)
> | > |
> | > | So now I'm stuck as to what I need to do now.  Any help would be
> | > | appreciated!
> | > |
> | > |
> | > |
> | > |
> | > |
> | > |
> | > |
> | > |
> | > |
> | >
> |
> |
> |
> 


0
paul419 (11)
10/28/2005 6:32:13 PM
You're welcome Paul.

Good luck!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no 
rights.)


--------------------
| From: "Paul" <paul419@community.nospam>
| References: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl> 
<z#EN#6q2FHA.1144@TK2MSFTNGXA01.phx.gbl> 
<OY7ZVix2FHA.3092@TK2MSFTNGP10.phx.gbl> 
<spDLsI22FHA.1144@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Add XmlNode
| Date: Fri, 28 Oct 2005 11:32:13 -0700
| Lines: 311
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <Oig4v3#2FHA.3900@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9111
| X-Tomcat-NG: microsoft.public.dotnet.xml
| 
| Thanks again, Steven.
| 
| Based on your response, the approach I'm going to take is to generate the
| prefixes myself which I've implemented and it appears to work.
| 
| Anyway, your help got me out of a corner, thank you.
| 
| Paul
| 
| "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message 
| news:spDLsI22FHA.1144@TK2MSFTNGXA01.phx.gbl...
| > Thanks for your response Paul,
| >
| > As for namespace prefix, it doesn't  matter much. Namespace prefix is 
just
| > like an alias of the actual Namespace  URI, so we can choose 
discretionary
| > ones as we like.  And prefix value won't make XML document different as
| > long as the Namespace URI is the same between multiple documents.
| > e.g.
| >
| > the following xmlelement is identical to each other:
| > [1]
| > <ns0:hello  xmlns:ns0="http://www.hello.org" >
| > <ns0:helloWorld>hello</ns0:helloWorld>
| > </ns0:hello>
| >
| > [2]
| > <ns1:hello xmlns:ns1="http://www.hello.org">
| > <ns1:helloWorld>hello</ns1:helloWorld>
| > </ns1:hello>
| >
| > though the namespace prefix is different( "ns0" and "ns1"), their actual
| > Namespace URI are the same. So they're identical.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | From: "Paul" <paul419@community.nospam>
| > | References: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
| > <z#EN#6q2FHA.1144@TK2MSFTNGXA01.phx.gbl>
| > | Subject: Re: Add XmlNode
| > | Date: Thu, 27 Oct 2005 10:04:59 -0700
| > | Lines: 222
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <OY7ZVix2FHA.3092@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.xml
| > | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9100
| > | X-Tomcat-NG: microsoft.public.dotnet.xml
| > |
| > | Hello Steven and thank you for your reply!!
| > |
| > | Your solution worked well and it seems that
| > | the part I was missing was that I needed to ask
| > | the document to create the new XmlAttribute and not
| > | the newly created node.
| > |
| > | I do have a followup question.  In your solution you hard-
| > | code the namespace prefix 'a4' as follows:
| > |
| > |     doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
| > |     nsattr.InnerText =
| > |
| > 
"http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
| > |
| > 
n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
| > |
| > |
| > | But what if I don't know what the prefix is?  It seems that I should 
ask
| > the
| > | document
| > | to generate a new one for me if one doesn't already exist.  But on
| > | XmlDocument I only
| > | see:
| > |
| > |     GetPrefixOfNamespace  and
| > |     GetNamespaceOfPrefix
| > |
| > | Paul
| > |
| > |
| > |
| > | "Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
| > | news:z%23EN%236q2FHA.1144@TK2MSFTNGXA01.phx.gbl...
| > | > Hi Paul,
| > | >
| > | > Welcome to MSDN newsgroup.
| > | > Regarding the adding XmlNode into XmlDocument question you 
mentioned, 
| > we
| > | > can just use the XmlDocument.CreateElement to create a Element xml 
| > node
| > | > and
| > | > then locate the parent node where we want to append the new element.
| > Then,
| > | > we can use the XmlElement(XmlNode) 's AppendChild method to add the 
| > new
| > | > element.  Also, in your scenario, your element has some additional
| > | > namespace declaration attributes, we need to append them into the 
new
| > | > element or in the document also. here is a simple example on 
creating 
| > a
| > | > new
| > | > xmlelement and add into a existing xmldoument:
| > | >
| > | > the original document is like:
| > | >
| > | > =================
| > | > <?xml version="1.0" encoding="utf-8" ?>
| > | > <root xmlns="http://www.mytest.org">
| > | > <datas>
| > | > <data id="1">
| > | > <item>fsfdsfs</item>
| > | > </data>
| > | > <data id="2">
| > | > <item>fksfjkdsjfdks</item>
| > | > </data>
| > | > </datas>
| > | > </root>
| > | > ===================
| > | >
| > | > the code that modify the document is:
| > | > ====================
| > | > static void RunXmlDoc()
| > | > {
| > | > XmlDocument doc = new XmlDocument();
| > | > doc.Load(@"..\..\testxml.xml");
| > | >
| > | > XmlElement elm = doc.CreateElement("PayPerference");
| > | >
| > | > elm.InnerText = "cash";
| > | >
| > | >
| > | > XmlAttribute nsattr = null;
| > | >
| > | > nsattr =
| > | > doc.CreateAttribute("xmlns","xsi","http://www.w3.org/2000/xmlns/");
| > | > nsattr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";
| > | >
| > | > elm.Attributes.Append(
| > | > nsattr
| > | > );
| > | >
| > | > //
| > | > nsattr =
| > | > doc.CreateAttribute("xmlns","a4","http://www.w3.org/2000/xmlns/");
| > | > nsattr.InnerText =
| > | >
| > 
"http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomai
| > | >
| > 
n%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull";
| > | >
| > | > elm.Attributes.Append(
| > | > nsattr
| > | > );
| > | >
| > | >
| > | > nsattr =
| > | >
| > 
doc.CreateAttribute("xsi","type","http://www.w3.org/2001/XMLSchema-instance"
| > | > );
| > | > nsattr.InnerText = "a4:Customer+CustomerPayOptions";
| > | > elm.Attributes.Append(
| > | > nsattr
| > | > );
| > | >
| > | > XmlNamespaceManager manager = new 
XmlNamespaceManager(doc.NameTable);
| > | > manager.AddNamespace("ns1","http://www.mytest.org");
| > | >
| > | > XmlElement datas = 
doc.SelectSingleNode("/ns1:root/ns1:datas",manager)
| > | > as XmlElement;
| > | >
| > | > datas.AppendChild(elm);
| > | >
| > | >
| > | >
| > | > Console.WriteLine(doc.OuterXml);
| > | >
| > | > doc.Save("output.xml");
| > | >
| > | > }
| > | > ===========================
| > | >
| > | > The output.xml will be something like;
| > | >
| > | > ========================
| > | > <?xml version="1.0" encoding="utf-8"?>
| > | > <root xmlns="http://www.mytest.org">
| > | >  <datas>
| > | >    <data id="1">
| > | >      <item>fsfdsfs</item>
| > | >    </data>
| > | >    <data id="2">
| > | >      <item>fksfjkdsjfdks</item>
| > | >    </data>
| > | >    <PayPerference 
| > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| > | >
| > 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
| > | >
| > 
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
| > | > %3Dnull" xsi:type="a4:Customer+CustomerPayOptions"
| > | > xmlns="">cash</PayPerference>
| > | >  </datas>
| > | > </root>
| > | > ============================
| > | >
| > | > Also, you can find the the "PayPerference" element in the output 
has 
| > an
| > | > empty default namespace
| > | >
| > | > xmlns=""
| > | >
| > | > you can explicitly specify the default namespace by changing the
| > | > XmlElement's construction to below:
| > | >
| > | > XmlElement elm =
| > | > doc.CreateElement("PayPerference","http://www.mycustomapp.com");
| > | >
| > | > Hope helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers 
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | From: "Paul" <paul419@community.nospam>
| > | > | Subject: Add XmlNode
| > | > | Date: Wed, 26 Oct 2005 11:29:29 -0700
| > | > | Lines: 28
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <uhI90sl2FHA.700@TK2MSFTNGP15.phx.gbl>
| > | > | Newsgroups: microsoft.public.dotnet.xml
| > | > | NNTP-Posting-Host: 66.236.123.34.ptr.us.xo.net 66.236.123.34
| > | > | Path: 
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9085
| > | > | X-Tomcat-NG: microsoft.public.dotnet.xml
| > | > |
| > | > | Here I have the definition of an XmlNode which is a property
| > | > (PayPreference)
| > | > | on my Customer class containing an enum describing how the 
customer
| > will
| > | > | pay.
| > | > |
| > | > | <PayPerference xsi:type="a4:Customer+CustomerPayOptions"
| > | > |
| > | >
| > 
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage
| > | >
| > 
/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken
| > | > %3Dnull">cash</PayPerference>
| > | > |
| > | > | I now want to add this XmlNode to a different Xml file where the
| > | > Customer
| > | > | class has not defined a PayPreference property.  I get as far as
| > | > locating
| > | > | the parent XmlNode (Customer).  Now I just need to add the XmlNode
| > | > defined
| > | > | above.  To do this, I understand that I need to ask the 
XmlDocument 
| > to
| > | > | create the node first before I ask the Customer node to
| > 'AppendChild'.
| > | > I
| > | > | notice 3 overloads of CreateElement on the XmlDocument to do this:
| > | > |
| > | > |     CreateElement(string name)
| > | > |     CreateElement(string qualifiedName, string namespaceURI)
| > | > |     CreateElement(string prefix, string localName, string
| > namespaceURI)
| > | > |
| > | > | So now I'm stuck as to what I need to do now.  Any help would be
| > | > | appreciated!
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| > 
| 
| 
| 

0
stcheng1 (64)
10/31/2005 1:22:57 AM
Reply:

Similar Artilces:

Add Lookup Fields to Entity
I need to add 4 "technical contact" fields (which would lookup the Contact entity) to the CONTRACT form. Is this possible? I've found it difficult to figure out what to do first. Thanks in advance, Brandon Not possible. You cant have multiple lookups for the same entity. You also cannot create new relationships between two system entitites. This will work in 4.0 Not possible, Pezman. N:M relationships are not possible in 3.0 yet. There is a alternative solution: a new entity to act as an N:M relationship. In your case, Contract/Contact. This entity has two 1:N relations...

Excel Add Ins
What is the name of the template wizard with Data Tracking (Excel. I can not locate the add in template wizard with Data Tracking in Office 2003 Hi Richard You are not the only one<g> The Add-in is working in 2003 only the install file is not working. Copy the xla file from a PC with 2002 to the PC with 2003 and it will work(use Tools>add-ins to browse to the file in Excel) -- Regards Ron de Bruin http://www.rondebruin.nl "Richard" <Richard@discussions.microsoft.com> wrote in message news:193C5DFD-578D-48F7-B9D6-9FEF5BDCEB64@microsoft.com... > What is t...

add a row or column to a single cell in exel
I am trying to split a single cell into 2 rows can you help If I understood correctly you want to enter an entry in two lines in a cell at appropirate place hit lt+enter and again hit enter for e.g venkat (alt+enter) raman(enter) "trev" <trev@discussions.microsoft.com> wrote in message news:89B2C15C-057F-43B9-8282-37923D5EA397@microsoft.com... > I am trying to split a single cell into 2 rows can you help ...

Add on
Hello, Here is a scenerio. A client is buying 1lb of ham. It is put on a waxed paper then wrapped into a white paper and then put into a shopping bag. The usage of shopping bag is 100% cases the usage of paper is only with certin categories of sales. Same with the waxed paper. Question: Is there a way of associating wax paper, white paper and shopping bags in a way so with every sale a piece of paper gets deducted from inventory and one bag is deducted from inventory? I would like to run a report every so often and see if I need to purchase any supplies. Kits and assembly do not work...

way to delete add. fr. auto. email add. function?
Is there a way to delete old or no longer used email addresses that appear in the drop down box when I am addressing a new email? Shebubba wrote: > Is there a way to delete old or no longer used email addresses that appear in > the drop down box when I am addressing a new email? That is the nickname cache. Search and delete the .nk2 file. That's the cache for nicknames (i.e., your manually entered e-mail addresses). If you only want to delete some of them, highlight an entry and hit the delete key. If that doesn't work, use Nirsoft's NK2 Viewer utility (it e...

POS 2009 Add-In: Populating a Task Pad
I would like to create a custom application that has the ability to maintain the items that are on certain Task Pads within POS 2009. These items would all be regular menu items (ex: hamburger, hot dog, french fries, etc) and not functions. For example, if a task pad was supposed to allow the cashier quick access to daily specials, then this custom application would need to be able to clear the task pad each day and add the items for that day. Is this going to be possible? Please provide some guidance. Thank you, Sean This is a multi-part message in MIME format. ------=_NextPart_00...

Add-in cannot be loaded OL07
Every time I open Outlook 2007 I get an error message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). It says the add-in cannot be loaded and has been disabled by Outlook. I've been getting this message ever since I uninstalled Winfax. How do I make this error stop appearing? Thanks. -- kapibarra Remove the addin from OL by using Trust Center, Addins. http://office.microsoft.com/en-us/outlook/HA100341271033.aspx#14 "kapibarra" wrote: > Every time I open Outlook 2007 I get an error > message regarding an add-in 'DCCExtensions' (DCCEXT32.DLL). ...

Format text to add character
I have two fields that should match, but one includes special characters while the other does not. Example: Field1 00ABCD123456123 Filed2 00/ABCD/123456/123/SBZ I need to find records where these two fields don't match, either by changing the display of one of them, or a query to compare Field1 character 7-15 with Field2 characters 9-14, 16-18. Hope this makes sense. Can anyone help? Thanks! Take a look at the following from the Access Help file it might be what you're looking for... Extract a part of a text value The following table lists examples of expressions that ...

Add File menu to custom toolbar
Hi All, I am trying to add the 'File" menu and "Window" menu of the Standard Toolbar to a custom toolbar but failing miserably! I think it should look something like: Sub AddMenuTitles() Application.CommandBars("MyCustomMenu").Controls.Add("File) Application.CommandBars("MyCustomMenu").Controls.Add("Window") End Sub Can anybody help please Regards Michael Sub test() AddMenuTitles True ' or false to delete End Sub Sub AddMenuTitles(bAdd As Boolean) Dim cbr As CommandBar Dim cbP As CommandBarPopup ...

add a DC in a LegSite
Hi, In the disaster recovery plan we want to create a leg site and put a DC in it. Here are some questions on how to achieve this smoothly. 1. Should I create the new site/subnet first and then promote a server in that subnet/site to DC, or should I promote a server in existing site/subnet and then move this DC to the new site/subnet? 2. When promoting a server to DC, should the server be a member server (already joined the domain) or just a workgroup member (no domain membership)? 3. The DC will be an AD-integrated DNS server. Should I install the DNS component (but not confi...

How can I add the customer's PO# to the drop-ship Purchase Order?
Our purchasing agent would like to be able to have the customers PO# from the Sales Transaction Entry screen show up on the PO's. Is this doable in Report Writer or can it not be done? We are using GP v9.0. As I still consider myself a newbie with RW, I would appreciate detailed instructions if possible. Thank you in advance for all responses. It is not possible thru traditional table relationships in Report Writer. Let me explain: you can certainly link the Purchase Order Work table to the SOP_POLink table and the SOP_POLink table to the SOP Transactions Work table, but will...

excel add-ons
Awhile back, there was an add-on for excel that had a lot more tools. It showed on the toolbar. Somehow I lost it and I would like to get it back. It had a lot of tools like for changing case and fill ins. Any help wouyld be great. Maybe ASAP Utilities. Try a 'net search for this add-in. Gord Dibben MS Excel MVP On Sun, 22 Mar 2009 20:22:43 -0400, "kmkx70a" <kmkx70a@prodigy.net> wrote: >Awhile back, there was an add-on for excel that had a lot more tools. It >showed on the toolbar. Somehow I lost it and I would like to get it back. It >had a lot of t...

Having OL automatically add a bcc: address
My boss wants to add me as a bcc: to every email she sends. Is there a way to set this up to happen automatically? Please reply to matt@lkigroup.com Thanks much. Matt ...

Map Add-On?
I am looking for an Excel Chart add on so that I can take numerical data and display it on a geographic map of states or zip codes for example. Even better I could color or shade a state based on the values in my spreadsheet. Any suggestions would be appreciated. Mark ...

How to add a VScroll to a CStatic Object
I create a CStatic object and write some text to the object but the text is too long to display in the work area but I don't konw how to add a vscroll to a CStatic object who can help me? I would say instead of a CStatic, use a CEdit control with the ReadOnly flag set. Because static controls by default aren't scrollable, so even if you add a scrollbar to it, you will have to manage the entire thing yourself (drawing, scrolling....), more trouble than it's worth. Ali R. "Smallfrogs" <super_smallfrogs@hotmail.com> wrote in message news:eLAO92y7DHA.2832@tk2msft...

Add ContractLine Entity in Menu
Hi, Is it possible to add a shortcut in the Service Menu to the ContractLine Entity? I really appreciate if someone could help. Regards, Alcides ...

Problem- add-in Access Outlook Add-in for Data Collection & Publis
I have a problem with Outlook 2007 and the add-in Access Outlook Add-in for Data Collection and Publishing. This add-in worked when I first installed Outlook 2007 when installing Office 2007 Enterprise. The add-in created a sub-folder in my Inbox named Data Collection Replies and worked well until about 6 weeks ago. Now I can’t get the add-in to work at all even though it appears in the list of COM.adds in Outlook 2007. More perplexing is the error message I now receive EVERY time I click on any email message to read it. The message is titled ‘Custom UI Runtime Error in...

Add target to trend chart
I've created a chart trending our company's daily rank over time. We have a specific rank as a target goal, and I'd like that to appear as a flat line on the chart, so we know how far we have to go. How can I get such a line, without having to populate a new column with the same number? Thanks Two options, 1) Simply draw a line where your target is at using the drawing toolbar. 2) Add an additional series to your chart containing two points. The X value of the points indicates the length of your line. The Y values should be set to your target. "Patience" <...

How To Add Filters To Add Ins List ???
I am using Power Point 2003 with XP Pro OS. I have install the conversion to read office 2007. When I use the Add In, it only shows 2003 power point extension .ppt How do I add the ability to show 2007 power point files too ??? Can someone tell me what I need to do to add the ability to see 2007 power point files??? I is very knowledgeable on VBA. Thank You, Gary You have to have all the Windows updates as of the time the Compatibility Pack was released. That was around October 2008, so you should have those. :-) That said, my Office 2003 installation on Windows...

Can I add other data to a pivot chart
I want to add a target line to a pivot chart. The data for the target line would be from a different source (worksheet) to the underlying pivot table. Is this possible (by workaround or otherwise)? A pivot chart can only display data from the pivot table. This can be overcome by drawing a line and hoping it doesn't move too much. I would instead make a regular chart from the pivot table, and add the data for the additional line. To make a regular chart from a pivot table, select a blank cell that's not touching the pivot table and start the chart wizard. In step 2, you must use...

Fill in form add picture
I have a Word doc that is a protected, fillable form. I want to add a field where people who edit the file can insert a picture/logo -when the file is protected. How do I do that? Thanks, Caroline See http://jay-freedman.info/form_picture.zip. It's a complicated scheme -- if you have trouble applying it to your form, contact me by email. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Caroline wrote: > I have a Word doc that is a protected,...

how do I add functions together in an excel Chart?
I am trying to determine the equation for three different functions in a scatter plot on graph in excel. I then want to have excel add these functions together. Does anyone know how to perform these functions? You can use the trendline feature to determine the formula. Select a series, then use Add Trendline from the Chart menu. To add these functions together, you can add together coefficients of the individual trendlines. To avoid errors, display the trendline formulas with a high degree of precision: format the formula, and on the Number tab, choose a Scientific format with 15 dec...

I want to add 6% sales tax to the amount in a cell/column
I have a small spread sheet that I use and 1 of the columns is used to enter the amount paid for an item I would like to add 6% sales tax automaticly to the amount I enter Thanks Bob "Bobb1220" <Bobb1220@discussions.microsoft.com> wrote in message news:920D71CF-2E44-4648-9084-FA76203944E7@microsoft.com... > I have a small spread sheet that I use and 1 of the columns is used to enter > the amount paid for an item I would like to add 6% sales tax automaticly to > the amount I enter > > Thanks > > Bob Assuming your data is in A1, enter =A1*1.06 in some ...

Calling add customer / add item functionallity from addin
I am developing a new addin and would like to call the add customer and add item UI directly from my addin without having to switch back and forth between the addin and POS. Not actually wanting to add them to a transaction just the database. I could access the dB directly but I don't want to reinvent the wheel and I want to use RMS so all the entries and validation are sweet. Micro$oft crew if you are reading this and other posts, then you probably know why open source software is doing so well. Publish your full API for Version 1.2 and you might sell more product!!! ...

Add Shares
I downloaded my stock trading information directly from Penson Financial Services. When I imported the data into Money the program decided that it needed to "ADD SHARES" to makes sure that I wouldn't have a negative balance of shares in my account. But the program didn't do it correctly, giving me many more ADD SHARES than I need. When I go through and reconcile the register with the Excel Spreadsheet that I also created with the data, I find that I'll have three or more ADD SHARES when the account would zero out without them. When I try to delete the additional ...