Solved

Create Xml string and update table column using stored proc

Posted on 2008-10-30
2
715 Views
Last Modified: 2013-11-18
I have the following string stored in my database column called TreeXml.


<C filename="00013024228c4e24a79bae959588acd4" parents="9daf7c70ac37479b8f91ef7bd08e07e6" DateModified="1217355187" taxonomyId="6aa742c4edff43a798c9067a2a4e223c" typeId="514044723" typeName="Answer" title="No" description=""><Conclusion /><Ps><P name="Approved" value="true" /><P name="Global or Country" value="Global" /><P name="Display on Questionaire" value="EA" /><P name="SL/SSL Owner /Maintained" value="02" /><P name="Sort Key" value="125" /><P name="Unique Number" value="963478" /></Ps></C>


I need to update this string
to add a new attribute called "Modified" in the  <C ...so the new string sould be

<C filename="00013024228c4e24a79bae959588acd4" parents="9daf7c70ac37479b8f91ef7bd08e07e6" DateModified="1217355187" taxonomyId="6aa742c4edff43a798c9067a2a4e223c" typeId="514044723" typeName="Answer" title="No" description=""  Modified="xyz ">


i am getting this xyz value using this

Select top (1)  C.UserName as LastModifiedBy
      from      QMSDocuments D
                  join QMSTaxonomyNames T on D.TaxonomyID = T.TaxonomyID
                  join QMSChanges C on C.Rowid = D.Rowid
      where      DocumentID = '00013024228c4e24a79bae959588acd4' order by C.ChangeDate desc



How do i achieve all this  in a stored proc
0
Comment
Question by:angireddy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 22893903
Well the way to do this properly is to create an XML DOM and using the LoadXML() method to load the string you have read from the database into it.

You now need to select the "C" node like

    cNode = xmldom.selectSingleNode('/C');

and then create a new attribute node with

   attrNode = xmldom.CreateAttribute('Modified');

and then set it's value :-

    attrNode.Value = today();  // or whatever

now add the new attribute to the attribute of the C node

    cNode.attributes.setNamedItem(attrNode);

and then save the document into a string

    str = xmldom.xml

and then write the string back into the database.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML & .net 5 52
MS Access MSXML2 DomDocument.Load and XMLHTTP.Send Not Sending utf-8 Char Format Correctly 3 97
Advice in Xamarin 21 109
xslt 1.0 - How to split value 8 42
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question