Powershell - XML file query
Hello, I need to query an XML based file to extract info. I have used the line below in a script with success,
$Xml.category.machine | Select-Object -Property IP | format-table
based on querying an XML file formatted as below
<Category name="System Summary">
<!--1. machine details-->
<Machine test="22">
<Name>Server1</Name>
<IP>31.248.95.170</IP>
However the data I need to query is in the format of below. Can anyone help with how I can reference this to get output from below of Display_Name, State and Start_Mode (the 'Category' field is not unique in the 2nd file so ideally I would be able
to search for Category name="System Summary" but this doesn't work for me. Thanks!
<Category name="Services">
<Data>
<Display_Name><![CDATA[Adobe Flash Player Update Service]]></Display_Name>
<Name><![CDATA[AdobeFlashPlayerUpdateSvc]]></Name>
<State><![CDATA[Stopped]]></State>
<Start_Mode><![CDATA[Manual]]></Start_Mode>
<Service_Type><![CDATA[Own Process]]></Service_Type>
<Path><![CDATA[c:\windows\system32\macromed\flash\flashplayerupdateservice.exe]]></Path>
<Error_Control><![CDATA[Normal]]></Error_Control>
<Start_Name><![CDATA[LocalSystem]]></Start_Name>
<Tag_ID><![CDATA[0]]></Tag_ID>
</Data>
<Data>
Thanks jrv. When I ran $nfo=[xml](cat c:\main.nfo)
$nfo.SelectNodes('//Category[@name="Software Environment"]/Category[@name="Services"]/Data')
I got several lines of below so it seems to be accessing the right part of the nfo file - which is great.
Display_Name : Display_Name
Name : Name
State : State
Start_Mode : Start_Mode
Service_Type : Service_Type
Path : Path
Error_Control : Error_Control
Start_Name : Start_Name
Tag_ID : Tag_ID
When I ran
$nfo=[xml](cat \temp\system.nfo)
$nfo.SelectNodes('//Category[@name="Software Environment"]/Category[@name="Services"]/Data') |
ForEach-Object{
$p=[ordered]@{
Name=$_.Name.innerText
DisplayName=$_.Display_Name.innerText
Path=$_.Path.innerText
State=$_.State.innerText
StartMode=$_.Start_Mode.innerText
New-Object PsCustomObject -Property $p
} |ft -auto
I got lots of messages like below:
New-Object : Cannot validate argument on parameter 'Property'. The argument is null or empty. Supply an argument that is not null or em
pty and then try the command again.
At line:11 char:46
+ New-Object PsCustomObject -Property <<<< $p
+ CategoryInfo : InvalidData: (:) [New-Object], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.NewObjectCommand
Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
At line:4 char:23
+ $p=[ordered] <<<< @{
+ CategoryInfo : InvalidOperation: (ordered:String) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
Any ideas?
Similar Messages
-
Hi all,
From https://www.simple-talk.com/content/print.aspx?article=1756, I mimicked to create the following sql code to do Importing XML data using a CTE:
---Importing XML data using a CTE -----Ad-Hoc XML File Query--simple-talk---1020AM 27 Feb 2015
---query the XML Blob using a CTE (pulling from the XML file each time
USE OPENXMLtesting1
GO
With XmlFile (Contents) AS (
SELECT CONVERT (XML, BulkColumn)
FROM OPENROWSET (BULK 'C:\XML FilesMicrosoft-Samples\books.xml', SINGLE BLOB) AS XmlData
SELECT
FROM XmlFile
GO
I got the following message:
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'BLOB'.
I have no ideas why it is incorrect in that code statment. Please kindly help, advise and respond.
Thanks in advance,
Scott Chang
P. S. The books.xml file was copied from the Microsoft samples:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy.</description>
</book>
<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled.</description>
</book>
<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty
thousand leagues beneath the sea.</description>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches,
centipedes, scorpions and other insects.</description>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems
of being quantum.</description>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
</book>
<book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.</description>
</book>
</catalog>I found the mistakes I made and I corrected them. The newly revised/corrected code is:
USE OPENXMLtesting1
GO
With XmlFile (Contents) AS (
SELECT CONVERT (XML, BulkColumn)
FROM OPENROWSET (BULK 'C:\Temp\books.xml', SINGLE_BLOB) AS XmlData
SELECT *
FROM XmlFile
GO
It worked: Results
Contents
1 <catalog><book.id="bk101"><author>Gambardella.M...
If I clicked on this, I got a listing of the whole book.xml!! I don't know what it means. Please comment and respond.
Thanks,
Scott Chang -
Powershell XML file modification
Hi,
Could someone assist me with a Powershell / XML type question please, i am trying to write out element values in a nmde but its being writen at the wrong level, i cant seem to get it working.
Thanks
Source XML file
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<meta>
<manifestVersion>1.1</manifestVersion>
<createdDateTime>23.01.2014 14:16:53</createdDateTime>
<createdBy>EnterpriseTransporter, Version=5.0.3.7, Culture=neutral, PublicKeyToken=null</createdBy>
<modifiedDateTime>24.01.2014 16:15:41</modifiedDateTime>
<lastRunDateTime>24.01.2014 16:15:38</lastRunDateTime>
<lastRunDuration>2.74</lastRunDuration>
<lastRunMode>preview</lastRunMode>
</meta>
<options bulk="false" turbo="false" ignoreWarnings="true" triggerSlowsync="false" migrateWlan="false" />
<datasources>
<sourceDomain label="Source">
<defaults serverName="" />
</sourceDomain>
<destinationDomain label="Target">
<defaults serverName="" groupName="something" ITPolicyName="something2" SwConfigName="" />
</destinationDomain>
</datasources>
<users>
<user email="" destServer="" groupName="" ITPolicyName="" SwConfigName="" />
</users>
</manifest>
Script
$path = "C:\Script\bet\manifestsource.xml"
$csvPath = "C:\Script\bet\import.csv"
$doc = [xml](Get-Content -Path $path)
foreach($e in (Import-Csv -Path $csvPath))
$element = $doc.Manifest.users.user.clone()
$element.email = $e.useremail
$element.destServer = $e.destServer
$element.groupName = "Something"
$element.ITPolicyName = "Something2"
$element.SwConfigName = ""
$doc.DocumentElement.AppendChild($element)
$doc.Save("C:\Script\bet\manifest.xml")
This is what i get
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<meta>
<manifestVersion>1.1</manifestVersion>
<createdDateTime>23.01.2013 14:16:53</createdDateTime>
<createdBy>EnterpriseTransporter, Version=5.0.3.7, Culture=neutral, PublicKeyToken=null</createdBy>
<modifiedDateTime>24.03.2013 16:15:41</modifiedDateTime>
<lastRunDateTime>24.03.2013 16:15:38</lastRunDateTime>
<lastRunDuration>2.74</lastRunDuration>
<lastRunMode>preview</lastRunMode>
</meta>
<options bulk="false" turbo="false" ignoreWarnings="true" triggerSlowsync="false" migrateWlan="false" />
<datasources>
<sourceDomain label="Source">
<defaults serverName="" />
</sourceDomain>
<destinationDomain label="Target">
<defaults serverName="" groupName="HSFProd-Baseline" ITPolicyName="HSFGlobal" SwConfigName="" />
</destinationDomain>
</datasources>
<users>
<user email="" destServer="" groupName="" ITPolicyName="" SwConfigName="" />
</users>
<user email="[email protected]" destServer="server1" groupName="something" ITPolicyName="something2" SwConfigName="" />
<user email="[email protected]" destServer="server2" groupName="something" ITPolicyName="something2" SwConfigName="" />
<user email="[email protected]" destServer="server1" groupName="something" ITPolicyName="something2" SwConfigName="" />
</manifest>
This is what i need
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<meta>
<manifestVersion>1.1</manifestVersion>
<createdDateTime>23.01.2013 14:16:53</createdDateTime>
<createdBy>EnterpriseTransporter, Version=5.0.3.7, Culture=neutral, PublicKeyToken=null</createdBy>
<modifiedDateTime>24.03.2013 16:15:41</modifiedDateTime>
<lastRunDateTime>24.03.2013 16:15:38</lastRunDateTime>
<lastRunDuration>2.74</lastRunDuration>
<lastRunMode>preview</lastRunMode>
</meta>
<options bulk="false" turbo="false" ignoreWarnings="true" triggerSlowsync="false" migrateWlan="false" />
<datasources>
<sourceDomain label="Source">
<defaults serverName="" />
</sourceDomain>
<destinationDomain label="Target">
<defaults serverName="" groupName="HSFProd-Baseline" ITPolicyName="HSFGlobal" SwConfigName="" />
</destinationDomain>
</datasources>
<users>
<user email="[email protected]" destServer="server1" groupName="something" ITPolicyName="something2" SwConfigName="" />
<user email="[email protected]" destServer="server2" groupName="something" ITPolicyName="something2" SwConfigName="" />
<user email="[email protected]" destServer="server1" groupName="something" ITPolicyName="something2" SwConfigName="" />
</users>
</manifest>The following work perfectly for me:
$doc=[xml]@'
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<meta>
<manifestVersion>1.1</manifestVersion>
<createdDateTime>23.01.2014 14:16:53</createdDateTime>
<createdBy>EnterpriseTransporter, Version=5.0.3.7, Culture=neutral, PublicKeyToken=null</createdBy>
<modifiedDateTime>24.01.2014 16:15:41</modifiedDateTime>
<lastRunDateTime>24.01.2014 16:15:38</lastRunDateTime>
<lastRunDuration>2.74</lastRunDuration>
<lastRunMode>preview</lastRunMode>
</meta>
<options bulk="false" turbo="false" ignoreWarnings="true" triggerSlowsync="false" migrateWlan="false" />
<datasources>
<sourceDomain label="Source">
<defaults serverName="" />
</sourceDomain>
<destinationDomain label="Target">
<defaults serverName="" groupName="something" ITPolicyName="something2" SwConfigName="" />
</destinationDomain>
</datasources>
<users>
<user email="" destServer="" groupName="" ITPolicyName="" SwConfigName="" />
</users>
</manifest>
$user=$doc.SelectSingleNode('//users/user')
Import-Csv -Path c:\scripts\testman.csv |
ForEach-Object{
$u=$user.Clone()
$u.email = $_.useremail
$u.destServer = $_.destserv
$u.groupName = 'group'
$u.ITPolicyName = "Something2"
$uSwConfigName = ""
$doc.Manifest.users.AppendChild($u)
¯\_(ツ)_/¯ -
Hi all,
I learmed the basic stuff of XML, DTD, DOM, etc. long time ago. Now, I came back to resume my XML journey and try to learn the XML Schemas, XPath and XQuery. I have Microsoft SQL Server 2012 Management Studio (SSMS2012) in our computer network. From
Page 221 of the old Book "Beginning XML 2nd Edition" written by David Hunter, et.al., (published by Wrox), I copied the name5.xsd and name5.xml :
<?xml version="1.0"?>
<schema xmlns=http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.wrox.com/name" xmlns:target="http://www.wrox.com/name"
elementFormDefault="qualified">
<element name="name">
<complexType>
<sequence>
<element name="first" type="string"/>
<element name="middle" type="string"/>
<element name="last" type="string"/>
</sequence>
</complexType>
</element>
</schema>
<?xml version="1.0"?>
<name
xmlns=http://www.wrox.com/name"
xmlns:xsi="http://www.wrox.org/2001XMLSchema-instance"
xsi:schemaLocation="http://www.wrox.com/name name5.xsd"
title="Mr.">
<first>John</first>
<middle>Frizgerald</middle>
<last>Doe</last>
</name>
How can I execute these two files in my SSMS2012 for doing my first XML Schema trial?
Please kindly help, advise and respond.
Thanks in advance,
Scott ChangHi Eric Zhang, Thanks for your nice response.
1) I saw the CREATE XML SCHEMA COLLECTION (Transact-SQL) and tried its first example "Create XML schema collection in the database" in my SQL Server 2012 Management Studio (SSMS2012):
-- Create a sample database in which to load the XML schema collection.
-- Copied this set of code stsments from Microsoft Library (ms176009)
-- ColesMS12_20a.sql (saved in C:/Documents/SQL Server Management Studio)
-- 19 March 2015 1145 AM
CREATE DATABASE SampleDB
GO
USE SampleDB
GO
CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
N'<?xml version="1.0" encoding="UTF-16"?>
<xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
xmlns ="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:complexType name="StepType" mixed="true" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="tool" type="xsd:string" />
<xsd:element name="material" type="xsd:string" />
<xsd:element name="blueprint" type="xsd:string" />
<xsd:element name="specs" type="xsd:string" />
<xsd:element name="diag" type="xsd:string" />
</xsd:choice>
</xsd:complexType>
<xsd:element name="root">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="Location" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="LocationID" type="xsd:integer" use="required"/>
<xsd:attribute name="SetupHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="MachineHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LaborHours" type="xsd:decimal" use="optional"/>
<xsd:attribute name="LotSize" type="xsd:decimal" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
GO
-- Verify - list of collections in the database.
select *
from sys.xml_schema_collections
-- Verify - list of namespaces in the database.
select name
from sys.xml_schema_namespaces
-- Use it. Create a typed xml variable. Note collection name specified.
DECLARE @x xml (ManuInstructionsSchemaCollection)
GO
--Or create a typed xml column.
CREATE TABLE T (
i int primary key,
x xml (ManuInstructionsSchemaCollection))
GO
-- ////The following code statements are not used in order to create SampleDB
-- Clean up
---DROP TABLE T
---GO
---DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
---Go
---USE Master
---GO
---DROP DATABASE SampleDB
It worked and I got the following results:
1 4 NULL sys 2009-04-13 12:59:13.390 2012-02-10 20:16:02.097
65536 1 NULL ManuInstructionsSchemaCollection 2015-03-19 11:47:17.660 2015-03-19 11:47:17.660
http://www.w3.org/2001/XMLSchema
http://schemas.microsoft.com/sqlserver/2004/sqltypes
http://www.w3.org/XML/1998/namespace
http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions
But, I don't undertand (i) what SCHEMA COECTION is, (ii) what <xsd:schema targetNamespace=.....</xsd:complexType> are, (iii) How I can specify my "project specific" schema in the Microsoft SCHEMA COLLECTION to check my xml file.
2) I dived in the XQuery programmimng in SSMS2012 in the last few weeks. I used the examles of Ad-Hoc XML File Query by Seth Delconte (in
httpS://www.simple-talk.com/content/print.aspx?article=1756) in my SSMS2012. They worked. But I don't understand the (i) Importing XML data using a function, (ii) Using the XQuery contans()
function to find substrings, (iii)Efficiency comparisons in the article.
Please kindly help me in enlightening me to resolve the difficulties listed in 1) and 2).
Thanks,
Scott Chang -
How to get Hierarchical XML File from a Database Join Query !
Hi,
How can i get a Hierarchical XML File from a Database Join Query ?
Any join query returns repeated values as below:
BD17:SQL>select d.dname, e.ename, e.sal
2 from dept d
3 natural join
4 emp e
5 /
DNAME ENAME SAL
ACCOUNTING CLARK 2450
ACCOUNTING KING 5000
ACCOUNTING MILLER 1300
RESEARCH SMITH 800
RESEARCH ADAMS 1100
RESEARCH FORD 3000
RESEARCH SCOTT 3000
RESEARCH JONES 2975
SALES ALLEN 1600
SALES BLAKE 2850
SALES MARTIN 1250
SALES JAMES 950
SALES TURNER 1500
SALES WARD 1250
14 rows selected.
We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ROWSET>
- <ROW num="1">
<DNAME>ACCOUNTING</DNAME>
<ENAME>CLARK</ENAME>
<SAL>2450</SAL>
</ROW>
- <ROW num="2">
<DNAME>ACCOUNTING</DNAME>
<ENAME>KING</ENAME>
<SAL>5000</SAL>
</ROW>
- <ROW num="3">
<DNAME>ACCOUNTING</DNAME>
<ENAME>MILLER</ENAME>
<SAL>1300</SAL>
</ROW>
- <ROW num="4">
<DNAME>RESEARCH</DNAME>
<ENAME>SMITH</ENAME>
<SAL>800</SAL>
</ROW>
- <ROW num="5">
<DNAME>RESEARCH</DNAME>
<ENAME>ADAMS</ENAME>
<SAL>1100</SAL>
</ROW>
- <ROW num="6">
<DNAME>RESEARCH</DNAME>
<ENAME>FORD</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="7">
<DNAME>RESEARCH</DNAME>
<ENAME>SCOTT</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="8">
<DNAME>RESEARCH</DNAME>
<ENAME>JONES</ENAME>
<SAL>2975</SAL>
</ROW>
- <ROW num="9">
<DNAME>SALES</DNAME>
<ENAME>ALLEN</ENAME>
<SAL>1600</SAL>
</ROW>
- <ROW num="10">
<DNAME>SALES</DNAME>
<ENAME>BLAKE</ENAME>
<SAL>2850</SAL>
</ROW>
- <ROW num="11">
<DNAME>SALES</DNAME>
<ENAME>MARTIN</ENAME>
<SAL>1250</SAL>
</ROW>
- <ROW num="12">
<DNAME>SALES</DNAME>
<ENAME>JAMES</ENAME>
<SAL>950</SAL>
</ROW>
- <ROW num="13">
<DNAME>SALES</DNAME>
<ENAME>TURNER</ENAME>
<SAL>1500</SAL>
</ROW>
- <ROW num="14">
<DNAME>SALES</DNAME>
<ENAME>WARD</ENAME>
<SAL>1250</SAL>
</ROW>
</ROWSET>
Thank you for some help.
Nelson AlbertiHi,
I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
It can be easily scheduled as a background job to grab content on a daily basis etc ...
Regards,
Steven -
How to Parse this XML File and require below mentioned value as output using powershell script
Need values for below as an output for below xml file so help me with the script:
Under Criteria Tag-
TimeStamp Display Value
OID corresponding to display value for nodes "Criterion"
Under Report Body Tag--
name in Report Section and OID value
<?xml version="1.0" encoding="UTF-8"?>
<ReportOutput>
<ReportHead>
<Report name="Execution Action" type="detailedchanges_rpt">
<Description></Description>
</Report>
<Criteria>
<TimestampCriterion name="date" displayvalue="08/10/14 23:08">
<Timestamp displayvalue="08/10/14 23:08">1412780929000</Timestamp>
</TimestampCriterion>
<MatchCriterion name="approvalId" displayvalue="Not applied" operator="contains" />
<MatchCriterion name="promotionComment" displayvalue="Not applied" operator="contains" />
<SelectCriterion name="changeWindow" displayvalue="Not applied" />
<SelectCriterion name="auditEvents" displayvalue="(Any)">
<String>auditEventAny</String>
</SelectCriterion>
<SelectCriterion name="attributeDisplay" displayvalue="Changed attributes">
<String>changed</String>
</SelectCriterion>
<SelectCriterion name="versionCompare" displayvalue="Version with current baseline">
<String>disabled</String>
</SelectCriterion>
<BooleanCriterion name="showContentDiff" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<BooleanCriterion name="displayUsers" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<BooleanCriterion name="displayPackages" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<BooleanCriterion name="displayCustomProperties" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<BooleanCriterion name="strictPackageMatch" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<BooleanCriterion name="displayCriteriaAtEnd" displayvalue="No">
<Boolean value="false" />
</BooleanCriterion>
<SelectCriterion name="elementExists" displayvalue="Not applied" />
<IntegerCriterion name="maxLinesPerBlock" displayvalue="10">
<Integer>10</Integer>
</IntegerCriterion>
<NodesCriterion name="nodes" displayvalue="TripwireENT.demo.net">
<OID>-1y2p0ij32e8bw:-1y2p0ij32e7cu</OID>
</NodesCriterion>
<MatchCriterion name="nodeName" displayvalue="Not applied" operator="contains" />
<CustomPropertiesCriterion name="nodeProps" displayvalue="Not applied" />
<RulesCriterion name="rules" displayvalue="Critical System Files">
<OID>-1y2p0ij32e7q2:-1y2p0ij31snh6</OID>
</RulesCriterion>
<MatchCriterion name="ruleName" displayvalue="Not applied" operator="contains" />
<MatchCriterion name="elementName" displayvalue="Not applied" operator="contains" />
<CustomPropertiesCriterion name="elementProps" displayvalue="Not applied" />
<CustomPropertiesCriterion name="versionProps" displayvalue="Not applied" />
<AttributesCriterion name="attributes" displayvalue="Not applied">
<Integer name=".missingImpliesFailure">1</Integer>
</AttributesCriterion>
<ContentCriterion name="content" displayvalue="Not applied" />
<MatchCriterion name="auditEventUserName" displayvalue="Not applied" operator="contains" />
<IntegerCriterion name="changeType" displayvalue="Added, Modified, Removed">
<Integer>7</Integer>
</IntegerCriterion>
<SeverityRangeCriterion name="severity" displayvalue="1 - 10000">
<Integer name="min">1</Integer>
<Integer name="max">10000</Integer>
</SeverityRangeCriterion>
<BooleanCriterion name="currentVersionsOnly" displayvalue="Yes">
<Boolean value="true" />
</BooleanCriterion>
<TimeRangeCriterion name="timeRange" displayvalue="All time" />
<PackagesCriterion name="packages" displayvalue="Not applied" />
<SortCriterion name="sortNodes" displayvalue="Name, ascending" isascending="true">
<String>name</String>
</SortCriterion>
<SortCriterion name="sortRules" displayvalue="Name, ascending" isascending="true">
<String>name</String>
</SortCriterion>
<SortCriterion name="sortElements" displayvalue="Name, ascending" isascending="true">
<String>name</String>
</SortCriterion>
<SortCriterion name="sortVersions" displayvalue="Date, descending" isascending="false">
<String>date</String>
</SortCriterion>
</Criteria>
</ReportHead>
<ReportBody>
<ReportSection name="TripwireENT.demo.net" category="node">
<OID>-1y2p0ij32e8bw:-1y2p0ij32e7cu</OID>
<String name="typeName">Windows Server</String>
<ReportSection name="Critical System Files" category="rule">
<OID>-1y2p0ij32e7q2:-1y2p0ij31snh6</OID>
<String name="typeName">Windows File System Rule</String>
<ReportSection name="C:\Temp" category="element">
<OID>-1y2p0ij32e8dr:-1y2p0ij32e586</OID>
<ReportSection name="08/10/14 22:48" category="version">
<OID>-1y2p0ij32e8du:-1y2p0ij32e3ho</OID>
<Integer name="changeType">1</Integer>
<String name="changeTypeName">Added</String>
<Integer name="severity">10000</Integer>
<String name="severityName">High</String>
<Timestamp name="changeTime" displayvalue="08/10/14 22:48">1412779682000</Timestamp>
<String name="approvalId"></String>
<ReportSection name="attributes" category="attributes">
<ReportSection name="DACL" category="added">
<String name="observed">Inherits Entries: true
NT AUTHORITY\SYSTEM, Access Allowed:
Standard rights:
Full Control
Modify
Read & Execute
List Folder Contents
Read
Write
Delete
Read Control
Write DAC
Write Owner
Synchronize
Specific rights:
Full Control
Traverse Folder / Execute File
List Folder / Read Data
Read Attributes
Read Extended Attributes
Create Files / Write Data
Create Folders / Append Data
Write Attributes
Write Extended Attributes
Directory Delete Child
Read Permissions
Change Permissions
Take Ownership
Header flags:
Object Inherit
Container Inherit
Inherited
BUILTIN\Administrators, Access Allowed:
Standard rights:
Full Control
Modify
Read & Execute
List Folder Contents
Read
Write
Delete
Read Control
Write DAC
Write Owner
Synchronize
Specific rights:
Full Control
Traverse Folder / Execute File
List Folder / Read Data
Read Attributes
Read Extended Attributes
Create Files / Write Data
Create Folders / Append Data
Write Attributes
Write Extended Attributes
Directory Delete Child
Read Permissions
Change Permissions
Take Ownership
Header flags:
Object Inherit
Container Inherit
Inherited
BUILTIN\Users, Access Allowed:
Standard rights:
Read & Execute
List Folder Contents
Read
Read Control
Synchronize
Specific rights:
Traverse Folder / Execute File
List Folder / Read Data
Read Attributes
Read Extended Attributes
Read Permissions
Header flags:
Object Inherit
Container Inherit
Inherited
BUILTIN\Users, Access Allowed:
Specific rights:
Create Folders / Append Data
Header flags:
Container Inherit
Inherited
BUILTIN\Users, Access Allowed:
Specific rights:
Create Files / Write Data
Header flags:
Container Inherit
Inherited
CREATOR OWNER, Access Allowed:
Generic rights:
Generic All
Specific rights:
Full Control
Traverse Folder / Execute File
List Folder / Read Data
Read Attributes
Read Extended Attributes
Create Files / Write Data
Create Folders / Append Data
Write Attributes
Write Extended Attributes
Directory Delete Child
Read Permissions
Change Permissions
Take Ownership
Header flags:
Object Inherit
Container Inherit
Inherit Only
Inherited
</String>
</ReportSection>
<ReportSection name="Group" category="added">
<String name="observed">TRIPWIREENT\None</String>
</ReportSection>
<ReportSection name="Owner" category="added">
<String name="observed">BUILTIN\Administrators</String>
</ReportSection>
<ReportSection name="Read-Only" category="added">
<String name="observed">false</String>
</ReportSection>
<ReportSection name="SACL" category="added">
<String name="observed">(null)</String>
</ReportSection>
<ReportSection name="Type" category="added">
<String name="observed">Directory</String>
</ReportSection>
</ReportSection>
</ReportSection>
</ReportSection>
<ReportSection name="C:\Windows\System32\drivers\etc\hosts" category="element">
<OID>-1y2p0ij32e8dr:-1y2p0ij32e4kp</OID>
<ReportSection name="08/10/14 23:08" category="version">
<OID>-1y2p0ij32e8du:-1y2p0ij32e3hk</OID>
<Integer name="changeType">2</Integer>
<String name="changeTypeName">Modified</String>
<Integer name="severity">10000</Integer>
<String name="severityName">High</String>
<Timestamp name="changeTime" displayvalue="08/10/14 23:08">1412780929000</Timestamp>
<String name="approvalId"></String>
<ReportSection name="attributes" category="attributes">
<ReportSection name="SHA-1" category="modified">
<String name="expected">de375d8a456a7345323babee88975ca567a2d5c4</String>
<String name="observed">3c5520382f91cb1cd898fee2da4eba3fa338d982</String>
</ReportSection>
<ReportSection name="Size" category="modified">
<String name="expected">829</String>
<String name="observed">854</String>
</ReportSection>
</ReportSection>
</ReportSection>
</ReportSection>
</ReportSection>
</ReportSection>
<ReportSection name="reportTotals" category="reportTotals">
<Integer name="summary.nodeCount">1</Integer>
<Integer name="summary.ruleCount">1</Integer>
<Integer name="summary.elementCount">2</Integer>
</ReportSection>
</ReportBody>
</ReportOutput>Hi Ritehere,
I know this is simple but am beginner in Powershell Script so I was looking for logic to go through however the output you provided is not what i am looking for and your script is too complicated, as under timestamp i wanted display value and correspoding
to display value the OID name and then name value correspoding to that OID. May be u got it wrong.
Thanks anyways. -
How can I query data from XML file stored as a CLOB ?
Hi folks,
please see below sample of XML file, which is stored in "os_import_docs", column "document" as CLOB.
I would like to query this XML file using some SQL select.
How can I query data form below XML?
<?xml version="1.0" encoding="UTF-8"?>
<etd>
<header>
<AR>000000000</AR>
<AW>0</AW>
<CT>S</CT>
<CU>H</CU>
<CZ>SS48</CZ>
<BU>4</BU>
<CH>0032</CH>
<CK>2012-11-01</CK>
<CL>21:18</CL>
<CW>225</CW>
<CX>0</CX>
<CF>SS-CZL18</CF>
<DV>2</DV>
</header>
<account_group id="234">
<account id="234">
<invoice id="000742024">
<da>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>A</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>88754515</BS>
<AD>Mike Tyson</AD>
<AC>Mike Tyson</AC>
<AZ>CZ6521232465</AZ>
<AE/>
<CG>A</CG>
<AL>A</AL>
<BZ>.</BZ>
<AH>Some street</AH>
<AI/>
<AF>Some city</AF>
<AK>Kraj</AK>
<AG>CZ</AG>
<AJ>885 21</AJ>
<CR>21-11-2012</CR>
<AY>602718709</AY>
<AV>800184965</AV>
<AP/>
<AO/>
<AQ/>
<AN/>
</da>
<da>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>A</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>88754515</BS>
<AD>Mike Tyson</AD>
<AC>Mike Tyson</AC>
<AZ>CZ6521232465</AZ>
<AE/>
<CG>A</CG>
<AL>L</AL>
<BZ>Mike Tyson</BZ>
<AH>Some street</AH>
<AI/>
<AF>Some city</AF>
<AK>Kraj</AK>
<AG>CZ</AG>
<AJ>885 21</AJ>
<CR>21-11-2012</CR>
<AY/>
<AV>800184965</AV>
<AP/>
<AO/>
<AQ/>
<AN/>
</da>
<detaildc CH="0032" AB="234" BS="11888954" BB="32" BA="CZ" AT="" CI="7077329000002340342" AU="" DU="1Z48395" CB="CZK">
<dc>
<AW>0</AW>
<CT>D</CT>
<CU>C</CU>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<CV>8151</CV>
<BT>12111</BT>
<CJ>1</CJ>
<AM>0</AM>
<DR>PC</DR>
<DS/>
<DO>25-10-2012</DO>
<DQ>18:42</DQ>
<CE>1</CE>
<BH>8151</BH>
<CY>8151 SHELL MALKOVICE P</CY>
<DP>049336</DP>
<DT/>
<BQ/>
<BR>500000</BR>
<CN>30</CN>
<CM>030</CM>
<BO>160,00</BO>
<BF>38,900</BF>
<BC>6224,00</BC>
<BI>32,417</BI>
<CD>B</CD>
<BG>0,600</BG>
<BK>31,817</BK>
<BJ>0,000</BJ>
<DI>8</DI>
<BP>20,00%</BP>
<CC>CZK</CC>
<BM>5090,67</BM>
<BN>1018,13</BN>
<BL>6108,80</BL>
<BD>5090,67</BD>
<BE>1018,13</BE>
<DW>6108,80</DW>
<CO>Nafta</CO>
</dc>
</detaildc>
<dt>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>T</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>11888954</BS>
<BB/>
<BA>CZ</BA>
<DG>1</DG>
<CN>30</CN>
<CM>030</CM>
<DF>160,00</DF>
<DH>litr</DH>
<DJ>20,00%</DJ>
<DD>5090,67</DD>
<DE>1018,13</DE>
<DC>6108,80</DC>
<DB>CZK</DB>
<DA>P</DA>
<AX/>
<CQ/>
<CP/>
</dt>
<dt>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>T</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>11888954</BS>
<BB/>
<BA>CZ</BA>
<DG>2</DG>
<CN/>
<CM/>
<DF>160,00</DF>
<DH>litr</DH>
<DJ/>
<DD>5090,67</DD>
<DE>1018,13</DE>
<DC>6108,80</DC>
<DB>CZK</DB>
<DA/>
<AX/>
<CQ/>
<CP/>
</dt>
<dt>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>T</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>11888954</BS>
<BB/>
<BA>CZ</BA>
<DG>19</DG>
<CN/>
<CM/>
<DF/>
<DH/>
<DJ/>
<DD>5090,67</DD>
<DE>1018,13</DE>
<DC>6108,80</DC>
<DB>CZK</DB>
<DA/>
<AX/>
<CQ/>
<CP/>
</dt>
<dt>
<AR>000742024</AR>
<AW>0</AW>
<CT>D</CT>
<CU>T</CU>
<CH>0032</CH>
<BY>31-10-2012</BY>
<CA>25-10-2012</CA>
<AB>234</AB>
<AA>234</AA>
<BS>11888954</BS>
<BB/>
<BA>CZ</BA>
<DG>8</DG>
<CN/>
<CM/>
<DF/>
<DH/>
<DJ/>
<DD>5090,67</DD>
<DE>1018,13</DE>
<DC>6108,80</DC>
<DB>CZK</DB>
<DA/>
<AX/>
<CQ/>
<CP/>
</dt>
</invoice>
</account>
</account_group>
<footer>
<AR>999999999</AR>
<AW>0</AW>
<CT>S</CT>
<CU>T</CU>
<CZ>SS48</CZ>
<BU>4</BU>
<CH>0032</CH>
<CK>2012-11-01</CK>
<CL>23:04</CL>
<CW>225</CW>
<BX>1</BX>
<CS>7</CS>
<BW>0000000000000610880</BW>
</footer>
</etd>sample - not working:
select x.*
from os_import_docs d
,XMLTABLE('/etd/header'
PASSING httpuritype(d.document).getXML()
COLUMNS
response_status varchar2(50) PATH 'AR'
) x
where d.object_id = 2587058
and rownum = 1;
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6196, maximum: 4000)Many thanks,
TomasHello,
many thanks for the reply. Your examples are very usefull for me.
To answer your questions.
An XML structure:
/etd
/header - repeat in each row in output
/account_group/account
/invoice
/da - repeat for each details under "selected "invoice
/detaildc/dc - the lowest level
/detaildn/dn - the lowest level
/dt - repeat for each details under "selected "invoice
/footer - repeat in each row in outputI would like to to have a 1 row for each "record" in /detaildc section and include related nodes at higher levels.
Please see below XML file, which is simplified file of example in first post, but includes a complete xml structure which needs to be queried in db.
<?xml version="1.0" encoding="UTF-8"?>
<etd>
<header>
<AR>000000000</AR>
<CK>2012-10-31</CK>
<CF>SS-CZL19</CF>
</header>
<account_group id="234">
<account id="234">
<invoice id="EI08P4000">
<da>
<AR>EI08P4000</AR>
<AD>Mickey Mouse</AD>
</da>
<detaildc DU="1Z56655" CB="EUR">
<dc>
<DO>16-10-2012</DO>
<CY>ASFINAG POST_MAUT</CY>
<BM>1940,60</BM>
<CO>Dalnicni znamka</CO>
</dc>
</detaildc>
<detaildc DU="2Z55050" CB="EUR">
<dc>
<DO>17-10-2012</DO>
<CY>ASFINAG POST_MAUT</CY>
<BM>1328,10</BM>
<CO>Dalnicni znamka</CO>
</dc>
</detaildc>
<detaildc DU="2Z90001" CB="EUR">
<dc>
<DO>27-10-2012</DO>
<CY>ASFINAG POST_MAUT</CY>
<BM>185,10</BM>
<CO>Poplatek</CO>
</dc>
</detaildc>
<dt>
<AR>EI08P4000</AR>
<DG>8</DG>
</dt>
</invoice>
</account>
<account id="234">
<invoice id="EI13T7777">
<da>
<AR>EI13T7777</AR>
<AD>Mickey Mouse</AD>
</da>
<detaildc DU="1Z48302" CB="EUR">
<dc>
<DO>26-10-2012</DO>
<CY>SANEF 07706 A 07704</CY>
<BM>232,10</BM>
<CO>Dalnicni poplatek</CO>
</dc>
</detaildc>
<detaildc DU="1Z48302" CB="EUR">
<dc>
<DO>20-10-2012</DO>
<CY>TEST A 07704</CY>
<BM>30,10</BM>
<CO>Poplatek</CO>
</dc>
</detaildc>
<dt>
<AR>EI13T7777</AR>
<DG>8</DG>
</dt>
</invoice>
</account>
<account id="234">
<invoice id="EI327744">
<da>
<AR>EI327744</AR>
<AD>Mickey Mouse</AD>
</da>
<detaildn CI="707732 00000234" >
<dn>
<BY>30-10-2012</BY>
<BM>8,10</BM>
</dn>
</detaildn>
<detaildn CI="707732 00000234" >
<dn>
<BY>30-10-2012</BY>
<BM>399,50</BM>
</dn>
</detaildn>
<dt>
<AR>EI327744</AR>
</dt>
</invoice>
</account>
<account id="234">
<invoice id="EI349515">
<da>
<AR>EI349515</AR>
<AD>Mickey Mouse</AD>
</da>
<detaildc DU="1Z56514" CB="EUR">
<dc>
<DO>29-10-2012</DO>
<CY>ALLAMI AUTOPALYAKEZE</CY>
<BM>1240,60</BM>
<CO>Dalnicni znamka</CO>
</dc>
</detaildc>
<detaildc DU="1Z56515" CB="EUR">
<dc>
<DO>19-10-2012</DO>
<CY>ASFINAG POST_MAUT</CY>
<BM>7428,10</BM>
<CO>Dalnicni znamka</CO>
</dc>
</detaildc>
<detaildc DU="1Z56515" CB="EUR">
<dc>
<DO>12-10-2012</DO>
<CY>UK</CY>
<BM>954,10</BM>
<CO>Poplatek</CO>
</dc>
</detaildc>
<dt>
<AR>EI349515</AR>
<DG>8</DG>
</dt>
</invoice>
</account>
</account_group>
<footer>
<CZ>SS47</CZ>
<BU>4</BU>
<CH>0032</CH>
<CK>2012-10-31</CK>
<CL>01:25</CL>
</footer>
</etd>Expected output
AR CK CF AR4 AD DU CB DO CY BM CO AR5 DG CI BY BM6 CZ BU CH CK7 CL
0 41213 SS-CZL19 EI08P4000 Mickey Mouse 1Z56655 EUR 16-10-2012 ASFINAG POST_MAUT 1940,60 Dalnicni znamka EI08P4000 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI08P4000 Mickey Mouse 2Z55050 EUR 17-10-2012 ASFINAG POST_MAUT 1328,10 Dalnicni znamka EI08P4000 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI08P4000 Mickey Mouse 2Z90001 EUR 27-10-2012 ASFINAG POST_MAUT 185,10 Poplatek EI08P4000 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI13T7777 Mickey Mouse 1Z48302 EUR 26-10-2012 SANEF 07706 A 07704 232,10 Dalnicni poplatek EI13T7777 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI13T7777 Mickey Mouse 1Z48302 EUR 20-10-2012 TEST A 07704 30,10 Poplatek EI13T7777 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI327744 Mickey Mouse EI327744 707732 00000234 30-10-2012 8,10 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI327744 Mickey Mouse EI327744 707732 00000234 30-10-2012 399,50 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI349515 Mickey Mouse 1Z56514 EUR 29-10-2012 ALLAMI AUTOPALYAKEZE 1240,60 Dalnicni znamka EI349515 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI349515 Mickey Mouse 1Z56515 EUR 19-10-2012 ASFINAG POST_MAUT 7428,10 Dalnicni znamka EI349515 8 SS47 4 32 41213 01:25
0 41213 SS-CZL19 EI349515 Mickey Mouse 1Z56515 EUR 12-10-2012 UK 954,10 Poplatek EI349515 8 SS47 4 32 41213 01:25 -
I have created XML File from Query using below function:-
select dbms_xmlgen.getxml('
select * from tblreports where rownum<=1') from dual;
"(CLOB) <?xml version="1.0"?>
<ROWSET>
<ROW>
<REPORTID>preRES0011</REPORTID>
<ALIAS>Date wise Summary of pins Report</ALIAS>
<ACTIVE>Y</ACTIVE>
<TITLE>Date wise Summary of pins Report</TITLE>
<QUERY>select tsb.month1,
count(SIDNUMBER)GENERATED,
sum(case WHEN SERIALSTATUSID='SRS01' THEN 1 ELSE 0 END)NotAllocated,
SUM(CASE WHEN SERIALSTATUSID='SRS02' or SERIALSTATUSID='SRS03' or SERIALSTATUSID='SRS05' THEN 1 ELSE 0 END)ALLOCATED,
SUM(CASE WHEN SERIALSTATUSID='SRS02' or SERIALSTATUSID='SRS01' THEN 1 ELSE 0 END)NOTASSIGNEDTORESELLER,
SUM(CASE WHEN SERIALSTATUSID='SRS03' THEN 1 ELSE 0 END)READYTOACTIVATE,
sum(CASE WHEN SERIALSTATUSID='SRS05' THEN 1 ELSE 0 END)ACTIVATED,
sum(CASE WHEN SERIALSTATUSID='SRS06' THEN 1 ELSE 0 END)Terminated,
sum(CASE WHEN SCRAPSTATUSID='CST01' THEN 1 ELSE 0 END)scraped,
sum(CASE WHEN LOCKSTATUSID='CST01' THEN 1 ELSE 0 END)locked,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
from (SELECT TO_CHAR(CREATEDATE,'DD-MON-YYYY')MONTH1 ,PINUSAGEMODEID,SERIALBATCHID,SERIALIDCOUNT,CREATEDATE FROM TBLMSERIALBATCH )TSB,
tblmserial ts
where TSB.SERIALBATCHID=ts.SERIALBATCHID
and to_char(TSB.CREATEDATE,'MON-YYYY')='$1'
GROUP BY TSB.MONTH1
order by TO_DATE(MONTH1,'dd-mon-yyyy') DESC</QUERY>
<CONNECTIVITYID>C0001</CONNECTIVITYID>
<INPUTREQUIRED>Y</INPUTREQUIRED>
<INPUTNAME>Month</INPUTNAME>
<CREATEDATE>30-JAN-10</CREATEDATE>
<LASTMODIFIEDDATE>22-FEB-10</LASTMODIFIEDDATE>
<CREATEDBY>reportadmin</CREATEDBY>
<LASTMODIFIEDBY>reportadmin</LASTMODIFIEDBY>
<TITLEPARAM>Y</TITLEPARAM>
<SUBTITLE>Date wise Summary of pins Report For &1</SUBTITLE>
<ELEMENTTYPEID>AET002</ELEMENTTYPEID>
<REPORTTYPEID>RTP01</REPORTTYPEID>
<SORTFIELD>Disable</SORTFIELD>
</ROW>
</ROWSET>
But in that it is taking ''' for ' ' instead of '$1' it is taking '$1'
how to keep ' ' in XML file instead of &apos?You can use bcp with query out option
use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
see
http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Generate an xml file from Database query results
Hi, can anyone help me out with this problem I'm having. What are the steps in creating an xml file directly from the results of a database query. I currently have a very simply process that queries a database via a partner link. The query returns the data but it's from this point that I am stuck. I need to create an xml file with the data along with the xml tags. I've looked at dozens of tutorials with no luck.
I would greatly appreciate help with this.
bpel rookieShould be quite simple.
Create another partnerlink, configure it to use the file adapter, and write to an XML file. In this case you need to create an XML Schema (.xsd) of the file you want to create.
Before you write to the file, either add assign steps to copy individual attributes or use a transform activity to convert from the database format to the file (xml) format. -
Download RSS feed as xml file from Sharepoint Online using PowerShell
Hello
Our company sharepoint (Office 365) contains also several RSS feeds.
How it is possible to download xml file out of this feed (website) using PowerShell?
I can authenticate with sharepoint using CSOM but do not what to do next.
As service user is not administrator I cannot use "SPOService".
This script works OK for standard website, but not for Sharepoint.
$doc = New-Object System.Xml.XmlDocument
$doc.Load("http://www.{CompanySite}.com/feed/")
$doc.save("C:\temp\feed.xml")
I am getting this error when using for company Sharepoint:
"The remote server returned an error: (403) Forbidden."
Thanks for your time considering this question.
JozinHi Scott,
thanks for advice.
Combination of WebClient and Sharepoint Credentials is working OK:
$client = New-Object System.Net.WebClient
$client.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, $SecurePassword)
$client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$client.DownloadFile($SiteURL, $file) -
Master-details query to XML file?
Hi:
I'm new in XML and Oracle. I want to create XML file from two tables (master-details).
I made a small serach and tried some examples:
Say we have these tables:
CREATE TABLE "TEST_XML"
( "ID" NUMBER,
"NAME" VARCHAR2(15),
"AMOUNT" NUMBER,
CONSTRAINT "TEST_XML_PK" PRIMARY KEY ("ID") ENABLE
CREATE TABLE "TEST_XML2"
( "ID2" NUMBER,
"NAME2" VARCHAR2(20),
"AMOUNT2" NUMBER
ALTER TABLE "TEST_XML2" ADD CONSTRAINT "TEST_XML2_FK" FOREIGN KEY ("ID2")
REFERENCES "TEST_XML" ("ID") ENABLE
INSERT INTO TEST_XML VALUES (1,'A',50);
INSERT INTO TEST_XML VALUES (2,'B',30);
INSERT INTO TEST_XML VALUES (3,'C',70);
INSERT INTO TEST_XML2 VALUES (1,'AA',10);
INSERT INTO TEST_XML2 VALUES (1,'AB',20);
INSERT INTO TEST_XML2 VALUES (1,'AC',20);
INSERT INTO TEST_XML2 VALUES (2,'BA',10);
INSERT INTO TEST_XML2 VALUES (2,'BB',20);
INSERT INTO TEST_XML2 VALUES (3,'CA',20);
INSERT INTO TEST_XML2 VALUES (3,'CB',40);
INSERT INTO TEST_XML2 VALUES (3,'CC',10);
I want a query to create XML file contains data from TEST_XML table and for each row the related data from TEST_XML2 table.
I did some tries (working in iSQL*PLUS):
SET SERVEROUTPUT ON
DECLARE
v_ctx DBMS_XMLGEN.ctxType;
v_file Utl_File.File_Type;
v_xml CLOB;
v_more BOOLEAN := TRUE;
BEGIN
-- Create XML document from query.
v_ctx := DBMS_XMLGEN.newContext('select id,name,amount,cursor (select id2,name2,amount2 from test_xml2 t2 where t2.id2=t1.id) val from test_xml t1');
DBMS_XMLGEN.setMaxRows(v_ctx, 10);
DBMS_XMLGEN.setRowsetTag(v_ctx, 'CLAIM');
-- Output XML document to file.
v_file := Utl_File.FOpen('TEST_DIR', 'test1.xml', 'w');
WHILE v_more
LOOP
v_xml := DBMS_XMLGEN.GetXML(v_ctx,0);
EXIT WHEN dbms_xmlgen.getNumRowsProcessed(v_ctx) =0;
Utl_File.Put(v_file,v_xml);
END LOOP;
Utl_File.FClose(v_file);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,255));
Utl_File.FClose(v_file);
END;
But hte output wasn't as I wanted:
<CLAIM>
<ROW>
<ID>1</ID>
<NAME>A</NAME>
<AMOUNT>50</AMOUNT>
<VAL>
<VAL_ROW>
<ID2>1</ID2>
<NAME2>AA</NAME2>
<AMOUNT2>10</AMOUNT2>
</VAL_ROW>
<VAL_ROW>
<ID2>1</ID2>
<NAME2>AB</NAME2>
<AMOUNT2>20</AMOUNT2>
</VAL_ROW>
<VAL_ROW>
<ID2>1</ID2>
<NAME2>AC</NAME2>
<AMOUNT2>20</AMOUNT2>
</VAL_ROW>
</VAL>
</ROW>
<ROW>
<ID>3</ID>
<NAME>C</NAME>
<AMOUNT>70</AMOUNT>
<VAL>
<VAL_ROW>
<ID2>3</ID2>
<NAME2>CA</NAME2>
<AMOUNT2>20</AMOUNT2>
</VAL_ROW>
<VAL_ROW>
<ID2>3</ID2>
<NAME2>CB</NAME2>
<AMOUNT2>40</AMOUNT2>
</VAL_ROW>
<VAL_ROW>
<ID2>3</ID2>
<NAME2>CC</NAME2>
<AMOUNT2>10</AMOUNT2>
</VAL_ROW>
</VAL>
</ROW>
<ROW>
<ID>2</ID>
<NAME>B</NAME>
<AMOUNT>30</AMOUNT>
<VAL>
<VAL_ROW>
<ID2>2</ID2>
<NAME2>BA</NAME2>
<AMOUNT2>10</AMOUNT2>
</VAL_ROW>
<VAL_ROW>
<ID2>2</ID2>
<NAME2>BB</NAME2>
<AMOUNT2>20</AMOUNT2>
</VAL_ROW>
</VAL>
</ROW>
</CLAIM>
Notice that for each details (from TEST_XML2) there is <VAL> tag which I don't need beside i want a query which is applicable on all environments.
May anyone help me please......
Regards,
SaadThe following looks like it produces your desired output. I used the WITH to simulate your two tables so I didn't have to CREATE them. This runs on 10.2.0.1. I'm not sure what bugs you are referring to as SQL/XML is stable in 10g that I have seen. I'm sure some bugs exist somewhere in it, just not with this usage. Just start with the SELECT statement to run on your system.
WITH test_xml AS
(SELECT 1 ID, 'A' name, 50 amount FROM DUAL UNION ALL
SELECT 2, 'B', 30 FROM DUAL UNION ALL
SELECT 3, 'C', 70 FROM DUAL),
test_xml2 AS
(SELECT 1 ID2, 'AA' name2, 10 amount2 FROM DUAL UNION ALL
SELECT 1, 'AB', 20 FROM DUAL UNION ALL
SELECT 1, 'AC', 20 FROM DUAL UNION ALL
SELECT 2, 'BA', 10 FROM DUAL UNION ALL
SELECT 2, 'BB', 20 FROM DUAL UNION ALL
SELECT 2, 'BC', 20 FROM DUAL UNION ALL
SELECT 3, 'CA', 20 FROM DUAL UNION ALL
SELECT 3, 'CB', 40 FROM DUAL UNION ALL
SELECT 3, 'CC', 10 FROM DUAL)
SELECT XMLElement("CLAIM",
XMLAgg(
XMLElement("ROW",
XMLForest(id "ID",
name "NAME",
amount "AMOUNT"),
(SELECT XMLAgg(XMLElement("VAL_ROW",
XMLForest(id2 "ID2",
name2 "NAME2",
amount2 "AMOUNT2")))
FROM test_xml2 t2
WHERE t2.id2=t1.id)
FROM test_xml t1This solution works in any environment where you can issue a SQL statement from, be it SQL*Plus, PL/SQL, Java, etc. -
How to generate XML file from oracle database query result
Hi dudes,
as stated on the subject, can anyone suggests me how can i achieve the task stated above??
Here is a brief description of my problem:
I need to create a XML file once i query from the oracle database, and the query result returned from the database will be stored in XML file.
I'd searched around the JAXB, DOM, SAXP and the like basic concepts, but i still don't know how to start??
Any suggestions ???Read this:
http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html
You might have to read more of the book to understand that chapter. -
Convert XML file into ABAP Query
Hi All,
Can we capture a XML file generated from a Non-SAP system in SAP system and convert into ABAP Query to retreive Data from DB and post it back as a XML query to the same Non-SAP system using a Middleware. Can this process be done in cache memory level itself instead of saving in DB.
If it is possible pls do tell the procedure and steps to be followed.
Suggestion and Help will be much Appreciated
Thanks & Regds.
RameshHi check these blogs....
<a href="/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach:///people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
<a href="/people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6:///people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6 -
How to make an XML file from SQL query on local disc (c:\temp)?
This query shows me XML results, but can I somehow make an XML file to local disc?
Thanks.
DECLARE @IMO NUMERIC(8,0)
DECLARE @Counter INT
SELECT @Counter = 1
WHILE ( @Counter <15 )
BEGIN
SET @IMO = (SELECT ImoNo from Vessel where ID=@Counter)
SELECT top 1
@IMO as ImoNumber,
VesselName,
Time,
lat as CurrentLatitude,
lon as CurrentLongitude,
sog as SpeedOverGround,
cog as CourseOverGround,
hdg as HeadingInDegrees,
GoingToCountry = (SELECT TOP 1 CountryName
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
GoingToHarbour = (SELECT TOP 1 Harbour
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
DestinationLatitude = (SELECT TOP 1 DestPosLAT
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ) ,
DestinationLongitude = (SELECT TOP 1 DestPosLON
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
ArrivalTime = (SELECT TOP 1 DestPosETA
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
GoingFromCountry = (SELECT TOP 1 CountryName
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc),
GoingFromHarbour = (SELECT TOP 1 Harbour
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc),
DepartureTime = (SELECT TOP 1 DestPosETD
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc)
FROM Position
WHERE ImoNo = @IMO
order by time desc
for Xml AUTO,elements,root('SplosnaPlovba')
SELECT @Counter = @Counter + 1
ENDYou can use bcp with query out option
use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
see
http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Change query string in ireport xml file?
greetings all
iam newbie to xml
first i want to add the xml file to a packge named first,how to do that?
second i want to change the query string to be
"select * from report where month= "+textfield.getText()
here's the code:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="Untitled_report_2"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="30"
rightMargin="30"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<queryString><![CDATA[SELECT * FROM report]]></queryString>
<field name="category" class="java.lang.String"/>
<field name="values" class="java.lang.Integer"/>
<field name="series" class="java.lang.String"/>
<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="0" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="0" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="201" isSplitAllowed="true" >
<stackedBar3DChart>
<chart hyperlinkTarget="Self" >
<reportElement
x="32"
y="21"
width="394"
height="144"
key="element-1"/>
<box></box>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF" >
</chartLegend>
</chart>
<categoryDataset>
<dataset >
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{series}]]></seriesExpression>
<categoryExpression><![CDATA[$F{category}]]></categoryExpression>
<valueExpression><![CDATA[$F{values}]]></valueExpression>
<itemHyperlink >
</itemHyperlink>
</categorySeries>
</categoryDataset>
<bar3DPlot >
<plot />
<categoryAxisFormat>
<axisFormat >
</axisFormat>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat >
</axisFormat>
</valueAxisFormat>
</bar3DPlot>
</stackedBar3DChart>
</band>
</detail>
<columnFooter>
<band height="3" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="0" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="0" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>the xml file
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="test"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="30"
rightMargin="30"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<queryString><![CDATA[SELECT * FROM report WHERE category BETWEEN 'week1' AND 'week4']]></queryString>
<field name="category" class="java.lang.String"/>
<field name="values" class="java.lang.Integer"/>
<field name="series" class="java.lang.String"/>
<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="50" isSplitAllowed="true" >
<staticText>
<reportElement
x="158"
y="7"
width="183"
height="37"
key="staticText-1"/>
<box></box>
<textElement>
<font size="14"/>
</textElement>
<text><![CDATA[ Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="50" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="30" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="4" isSplitAllowed="true" >
</band>
</detail>
<columnFooter>
<band height="2" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="0" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="194" isSplitAllowed="true" >
<stackedBar3DChart>
<chart hyperlinkTarget="Self" >
<reportElement
x="49"
y="-6"
width="369"
height="200"
key="element-1"/>
<box></box>
<chartLegend textColor="#000000" backgroundColor="#FFFFFF" >
</chartLegend>
</chart>
<categoryDataset>
<dataset >
</dataset>
<categorySeries>
<seriesExpression><![CDATA[$F{series}]]></seriesExpression>
<categoryExpression><![CDATA[$F{category}]]></categoryExpression>
<valueExpression><![CDATA[$F{values}]]></valueExpression>
<itemHyperlink >
</itemHyperlink>
</categorySeries>
</categoryDataset>
<bar3DPlot >
<plot />
<categoryAxisFormat>
<axisFormat >
</axisFormat>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat >
</axisFormat>
</valueAxisFormat>
</bar3DPlot>
</stackedBar3DChart>
</band>
</summary>
</jasperReport>the java code:
import java.sql.*;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperReport;
import java.io.OutputStream;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class ReportDriver {
public static void createAndShowGUI(){
Object[]obj={"1","2"};
JComboBox combo=new JComboBox(obj);
JFrame frame=new JFrame("Test");
JButton button=new JButton("Show Report");
frame.setLayout(new FlowLayout());
frame.setLocationRelativeTo(null);
frame.add(combo);
frame.add(button);
frame.setSize(150,100);
frame.setVisible(true);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
show_report();
public static void show_report(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/library", "root", "");
}catch(Exception ex) {ex.printStackTrace();}
try{
JasperDesign jasperDesign = JRXmlLoader.load("F:\\Program Files\\Xinox Software\\JCreatorV4\\MyProjects\\chart2\\src\\report.xml");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/library", "root", "");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, c);
JasperViewer.viewReport(jasperPrint);
}catch(Exception ex) {
String connectMsg = "Could not create the report " + ex.getMessage() + " " + ex.getLocalizedMessage();
System.out.println(connectMsg);
public static void main(String[] args) {
createAndShowGUI();
}the problem is i want when the user selects 2 from the combobox and presses the button
the where clause in the xml file is changed to BETWEEN 'week5' AND 'week8',how to do that?
Maybe you are looking for
-
How do I delete an app from my iphone 5 in ios 7?
I would like to delete an obsolete light app, how do I remove it? Thanks in advance.
-
Effect of super() in JDialog constructor on focusability/modality
Hello again, this is a JFrame which calls a JDialog which calls a JDialog. Using super(...) in the constructor of SecondDialog makes this dialog unfocusable as long as FirstDialog is shown. Without super(...) one can freely move between the dialogs.
-
TS3276 my server went down and now my email is not working, can anyone help please?
My website server went down and now my email is not working (though the server is back up) Does anyone know what I need to do? I'm told by my website hosts that I need to 'reconfigure authentication" but I have no idea how to do this, they are now cl
-
Is there a way to include images in a feature request to apple?
I often feel that that best way to convey my feature request is with an image showing an example of the request. Does anyone know of a way to include images along with your feature request? Thanks
-
Can't sync Outlook calendar to my iPhone 4
Stopped being able to sync my Outlook calendar when I switched from an iPhone 3 to 4