header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Creating XPathDocument object in Powershell
Last Post 13 Aug 2009 04:04 AM by halr9000. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
KotiUser is Offline
New Member
New Member
Posts:1
Avatar

--
12 Aug 2009 02:13 PM
    Hi,

    Can you please let me know how to create XPathDocument object in Powershell? Also please let me know if I need to load any .Net assemble to create that object.

    Here is the C# equivalent.

    XPathDocument doc = new XPathDocument("Example.xml");

    Thanks,
    Koti
    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    13 Aug 2009 04:04 AM
    Doesn't seem hard at all, actually, just did it.
    § HXRLAP2 {~} $wc = New-Object system.Net.WebClient § HXRLAP2 {~} $url = "http://halr9000.com/feed" § HXRLAP2 {~} $filepath = "$env:temp\test.xml" § HXRLAP2 {~} $wc.DownloadFile( $url, $filepath ) § HXRLAP2 {~} $xpath = New-Object system.Xml.XPath.XPathDocument( $filepath ) § HXRLAP2 {~} $xpath | gm TypeName: System.Xml.XPath.XPathDocument Name MemberType Definition ---- ---------- ---------- CreateNavigator Method System.Xml.XPath.XPathNavigator CreateNavigator() Equals Method System.Boolean Equals(Object obj) GetHashCode Method System.Int32 GetHashCode() GetType Method System.Type GetType() ToString Method System.String ToString() § HXRLAP2 {~} $xnav = $xpath.CreateNavigator() § HXRLAP2 {~} $xnav | gm TypeName: MS.Internal.Xml.Cache.XPathDocumentNavigator Name MemberType Definition ---- ---------- ---------- AppendChild Method System.Xml.XmlWriter AppendChild(), System.Void AppendChild(String newCh... AppendChildElement Method System.Void AppendChildElement(String prefix, String localName, String n... CheckValidity Method System.Boolean CheckValidity(XmlSchemaSet schemas, ValidationEventHandle... Clone Method System.Xml.XPath.XPathNavigator Clone() ComparePosition Method System.Xml.XmlNodeOrder ComparePosition(XPathNavigator other) Compile Method System.Xml.XPath.XPathExpression Compile(String xpath) CreateAttribute Method System.Void CreateAttribute(String prefix, String localName, String name... CreateAttributes Method System.Xml.XmlWriter CreateAttributes() CreateNavigator Method System.Xml.XPath.XPathNavigator CreateNavigator() DeleteRange Method System.Void DeleteRange(XPathNavigator lastSiblingToDelete) DeleteSelf Method System.Void DeleteSelf() Equals Method System.Boolean Equals(Object obj) Evaluate Method System.Object Evaluate(String xpath), System.Object Evaluate(String xpat... GetAttribute Method System.String GetAttribute(String localName, String namespaceURI) GetHashCode Method System.Int32 GetHashCode() GetNamespace Method System.String GetNamespace(String name) GetNamespacesInScope Method System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Versi... GetPositionHashCode Method System.Int32 GetPositionHashCode() GetType Method System.Type GetType() HasLineInfo Method System.Boolean HasLineInfo() InsertAfter Method System.Xml.XmlWriter InsertAfter(), System.Void InsertAfter(String newSi... InsertBefore Method System.Xml.XmlWriter InsertBefore(), System.Void InsertBefore(String new... InsertElementAfter Method System.Void InsertElementAfter(String prefix, String localName, String n... InsertElementBefore Method System.Void InsertElementBefore(String prefix, String localName, String ... IsContentKindMatch Method System.Boolean IsContentKindMatch(XPathNodeType typ) IsDescendant Method System.Boolean IsDescendant(XPathNavigator other) IsElementMatch Method System.Boolean IsElementMatch(String localName, String namespaceURI) IsKindMatch Method System.Boolean IsKindMatch(XPathNodeType typ) IsSamePosition Method System.Boolean IsSamePosition(XPathNavigator other) LookupNamespace Method System.String LookupNamespace(String prefix) LookupPrefix Method System.String LookupPrefix(String namespaceURI) Matches Method System.Boolean Matches(XPathExpression expr), System.Boolean Matches(Str... MoveTo Method System.Boolean MoveTo(XPathNavigator other) MoveToAttribute Method System.Boolean MoveToAttribute(String localName, String namespaceURI) MoveToChild Method System.Boolean MoveToChild(String localName, String namespaceURI), Syste... MoveToFirst Method System.Boolean MoveToFirst() MoveToFirstAttribute Method System.Boolean MoveToFirstAttribute() MoveToFirstChild Method System.Boolean MoveToFirstChild() MoveToFirstNamespace Method System.Boolean MoveToFirstNamespace(XPathNamespaceScope namespaceScope),... MoveToFollowing Method System.Boolean MoveToFollowing(String localName, String namespaceURI, XP... MoveToId Method System.Boolean MoveToId(String id) MoveToNamespace Method System.Boolean MoveToNamespace(String name) MoveToNext Method System.Boolean MoveToNext(), System.Boolean MoveToNext(String localName,... MoveToNextAttribute Method System.Boolean MoveToNextAttribute() MoveToNextNamespace Method System.Boolean MoveToNextNamespace(XPathNamespaceScope scope), System.Bo... MoveToParent Method System.Boolean MoveToParent() MoveToPrevious Method System.Boolean MoveToPrevious() MoveToRoot Method System.Void MoveToRoot() PrependChild Method System.Xml.XmlWriter PrependChild(), System.Void PrependChild(String new... PrependChildElement Method System.Void PrependChildElement(String prefix, String localName, String ... ReadSubtree Method System.Xml.XmlReader ReadSubtree() ReplaceRange Method System.Xml.XmlWriter ReplaceRange(XPathNavigator lastSiblingToReplace) ReplaceSelf Method System.Void ReplaceSelf(String newNode), System.Void ReplaceSelf(XmlRead... Select Method System.Xml.XPath.XPathNodeIterator Select(String xpath), System.Xml.XPat... SelectAncestors Method System.Xml.XPath.XPathNodeIterator SelectAncestors(XPathNodeType type, B... SelectChildren Method System.Xml.XPath.XPathNodeIterator SelectChildren(XPathNodeType type), S... SelectDescendants Method System.Xml.XPath.XPathNodeIterator SelectDescendants(XPathNodeType type,... SelectSingleNode Method System.Xml.XPath.XPathNavigator SelectSingleNode(String xpath), System.X... SetTypedValue Method System.Void SetTypedValue(Object typedValue) SetValue Method System.Void SetValue(String value) ToString Method System.String ToString() ValueAs Method System.Object ValueAs(Type returnType, IXmlNamespaceResolver nsResolver)... WriteSubtree Method System.Void WriteSubtree(XmlWriter writer) BaseURI Property System.String BaseURI {get;} CanEdit Property System.Boolean CanEdit {get;} HasAttributes Property System.Boolean HasAttributes {get;} HasChildren Property System.Boolean HasChildren {get;} InnerXml Property System.String InnerXml {get;set;} IsEmptyElement Property System.Boolean IsEmptyElement {get;} IsNode Property System.Boolean IsNode {get;} LineNumber Property System.Int32 LineNumber {get;} LinePosition Property System.Int32 LinePosition {get;} LocalName Property System.String LocalName {get;} Name Property System.String Name {get;} NamespaceURI Property System.String NamespaceURI {get;} NameTable Property System.Xml.XmlNameTable NameTable {get;} NodeType Property System.Xml.XPath.XPathNodeType NodeType {get;} OuterXml Property System.String OuterXml {get;set;} Prefix Property System.String Prefix {get;} SchemaInfo Property System.Xml.Schema.IXmlSchemaInfo SchemaInfo {get;} TypedValue Property System.Object TypedValue {get;} UnderlyingObject Property System.Object UnderlyingObject {get;} Value Property System.String Value {get;} ValueAsBoolean Property System.Boolean ValueAsBoolean {get;} ValueAsDateTime Property System.DateTime ValueAsDateTime {get;} ValueAsDouble Property System.Double ValueAsDouble {get;} ValueAsInt Property System.Int32 ValueAsInt {get;} ValueAsLong Property System.Int64 ValueAsLong {get;} ValueType Property System.Type ValueType {get;} XmlLang Property System.String XmlLang {get;} XmlType Property System.Xml.Schema.XmlSchemaType XmlType {get;}
    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer