PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Xquery

Reply

Xquery

 
Thread Tools Rate Thread
Old 22-12-2006, 12:28 PM   #1
=?Utf-8?B?TXVrZXNo?=
Guest
 
Posts: n/a
Default Xquery


hi all

I want to do some modification in my xmldata in xmldata column .
<root>
<DateOfBirth>12/22/1988 </DateOfBirth>
<Gender> 1 </Gender>
<Country>Bolivia </Country>
<moreDetails>
<AreaId>524</AreaId>
<City />
<State/>
<country />
<Pincode />

</moreDetails>

</root>
in the above xml i have to replace aall the child node of Moredetalis
wat query is best suited for that work


Regards,
Mukesh Kumar Agarwal
Senior Software Engineer
Efextra Solutions Pvt. Ltd
Noida- 201301
Delhi India
  Reply With Quote
Old 22-12-2006, 01:56 PM   #2
Rick
Guest
 
Posts: n/a
Default Re: Xquery

I think in general you could do something like this:

load the xml into an XMLDocument - Dim doc as XmlDocument =
XmlDocument.Load(...)

create an XmlDocumentFragment - Dim frag as XmlDocumentFragment =
doc.CreateDocumentFragment

write the new <moreDetails> to the frag

replace the existing <moreDetails> doc.ReplaceChild(frag, node to replace)

Totally untested, but I think you get the general idea.

Rick

> <root>
> <DateOfBirth>12/22/1988 </DateOfBirth>
> <Gender> 1 </Gender>
> <Country>Bolivia </Country>
> <moreDetails>
> <AreaId>524</AreaId>
> <City />
> <State/>
> <country />
> <Pincode />
>
> </moreDetails>
>
> </root>



  Reply With Quote
Old 23-12-2006, 09:55 AM   #3
=?Utf-8?B?TXVrZXNo?=
Guest
 
Posts: n/a
Default Re: Xquery

Hey Rick

I want to perform the action in storedprocedure
--
Regards,
Mukesh Kumar Agarwal
Senior Software Engineer
Efextra Solutions Pvt. Ltd
Noida- 201301
Delhi India


"Rick" wrote:

> I think in general you could do something like this:
>
> load the xml into an XMLDocument - Dim doc as XmlDocument =
> XmlDocument.Load(...)
>
> create an XmlDocumentFragment - Dim frag as XmlDocumentFragment =
> doc.CreateDocumentFragment
>
> write the new <moreDetails> to the frag
>
> replace the existing <moreDetails> doc.ReplaceChild(frag, node to replace)
>
> Totally untested, but I think you get the general idea.
>
> Rick
>
> > <root>
> > <DateOfBirth>12/22/1988 </DateOfBirth>
> > <Gender> 1 </Gender>
> > <Country>Bolivia </Country>
> > <moreDetails>
> > <AreaId>524</AreaId>
> > <City />
> > <State/>
> > <country />
> > <Pincode />
> >
> > </moreDetails>
> >
> > </root>

>
>
>

  Reply With Quote
Old 24-12-2006, 05:10 AM   #4
=?Utf-8?B?TWFuaXNoIEJhZm5h?=
Guest
 
Posts: n/a
Default RE: Xquery

Hi,
You can use the OPENXML function. The idea here is to
create a SProc to which
you'll pass your XML (usually as an NTEXT parameter). In the SProc you use
sp_xml_preparedocument to generate an in-memory "DOM-like" tree structure,
and then use OPENXML to shred the XML into relational rowsets. Below is a
link explaining how to use OPENXML that might help you get started (search
for "Using OPENXML"
in any search engine and you'll find some examples
there.)http://www.awprofessional.com/artic...7&seqNum=6&rl=1

Thanks and Regards,
Manish Bafna.
MCP and MCTS.


"Mukesh" wrote:

> hi all
>
> I want to do some modification in my xmldata in xmldata column .
> <root>
> <DateOfBirth>12/22/1988 </DateOfBirth>
> <Gender> 1 </Gender>
> <Country>Bolivia </Country>
> <moreDetails>
> <AreaId>524</AreaId>
> <City />
> <State/>
> <country />
> <Pincode />
>
> </moreDetails>
>
> </root>
> in the above xml i have to replace aall the child node of Moredetalis
> wat query is best suited for that work
>
>
> Regards,
> Mukesh Kumar Agarwal
> Senior Software Engineer
> Efextra Solutions Pvt. Ltd
> Noida- 201301
> Delhi India

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off